vend with
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package work
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/dbos-inc/dbos-transact-golang/dbos"
|
||||
)
|
||||
|
||||
func Workflow(ctx dbos.DBOSContext, arg any) (any, error) {
|
||||
log.Printf("WORKFLOW with %v!", arg)
|
||||
return nil, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"gitea.bel.blue/bel/with"
|
||||
"gitea.bel.blue/bel/with/cmd/example-dbos/work"
|
||||
mydbos "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")
|
||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return mydbos.QueueWorker(ctx, *conn, "queue", func(w *mydbos.Worker) error {
|
||||
mydbos.Can(w, work.Workflow)
|
||||
return w.Listen(ctx)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user