33 lines
819 B
Go
33 lines
819 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"log"
|
|
"os"
|
|
|
|
"gitea.bel.blue/bel/with"
|
|
"gitea.bel.blue/bel/with/cmd/example-dbos/work"
|
|
"gitea.bel.blue/bel/with/dbos"
|
|
)
|
|
|
|
func main() {
|
|
if err := with.Context(run); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func run(ctx context.Context) error {
|
|
fs := flag.NewFlagSet(os.Args[0], flag.ContinueOnError)
|
|
conn := fs.String("c", "", "postgresql://u:p@h:p/db")
|
|
gdedupe := fs.String("k1", "global-deduplication-key", "prevent ever re-evaluating this execution")
|
|
cdedupe := fs.String("k2", "concurrent-deduplication-key", "prevent re-evaluating this execution concurrently")
|
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
|
return err
|
|
}
|
|
|
|
return dbos.QueueClient(ctx, *conn, "queue", func(c *dbos.Client) error {
|
|
return dbos.Go(ctx, c, work.Workflow, 1, *gdedupe, *cdedupe)
|
|
})
|
|
}
|