println connected
This commit is contained in:
1
cmd/pg-queue/README.md
Normal file
1
cmd/pg-queue/README.md
Normal file
@@ -0,0 +1 @@
|
||||
https://topicpartition.io/blog/postgres-pubsub-queue-benchmarks
|
||||
31
cmd/pg-queue/main.go
Normal file
31
cmd/pg-queue/main.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"pg/src/with"
|
||||
|
||||
_ "github.com/lib/pq"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := with.Context(run); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
func run(ctx context.Context) error {
|
||||
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
||||
c := fs.String("c", "postgresql://pulsegres:pulsegres@localhost:15432", "conn string")
|
||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return with.PSQL(ctx, *c, func(pg *sql.DB) error {
|
||||
<-ctx.Done()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -49,6 +49,7 @@ func PSQL(ctx context.Context, conn string, foo func(db *sql.DB) error) error {
|
||||
}
|
||||
}
|
||||
}()
|
||||
log.Println("connected")
|
||||
|
||||
return foo(pg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user