diff --git a/cmd/pg-queue/README.md b/cmd/pg-queue/README.md new file mode 100644 index 0000000..a62db68 --- /dev/null +++ b/cmd/pg-queue/README.md @@ -0,0 +1 @@ +https://topicpartition.io/blog/postgres-pubsub-queue-benchmarks diff --git a/cmd/pg-queue/main.go b/cmd/pg-queue/main.go new file mode 100644 index 0000000..40f1794 --- /dev/null +++ b/cmd/pg-queue/main.go @@ -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 + }) +} diff --git a/src/with/pg.go b/src/with/pg.go index 222dcf5..c79dd93 100644 --- a/src/with/pg.go +++ b/src/with/pg.go @@ -49,6 +49,7 @@ func PSQL(ctx context.Context, conn string, foo func(db *sql.DB) error) error { } } }() + log.Println("connected") return foo(pg) }