Add three DBOS SDK skills with reference documentation for building reliable, fault-tolerant applications with durable workflows. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2.0 KiB
2.0 KiB
title, impact, impactDescription, tags
| title | impact | impactDescription | tags |
|---|---|---|---|
| Enqueue Workflows from External Applications | HIGH | Enables external services to submit work to DBOS queues | client, enqueue, external, queue |
Enqueue Workflows from External Applications
Use client.Enqueue() to submit workflows from outside your DBOS application. Since the Client runs externally, workflow and queue metadata must be specified explicitly by name.
Incorrect (trying to use RunWorkflow from external code):
// RunWorkflow requires a full DBOS context with registered workflows
dbos.RunWorkflow(ctx, processTask, "data", dbos.WithQueue("myQueue"))
Correct (using Client.Enqueue):
client, err := dbos.NewClient(context.Background(), dbos.ClientConfig{
DatabaseURL: os.Getenv("DBOS_SYSTEM_DATABASE_URL"),
})
if err != nil {
log.Fatal(err)
}
defer client.Shutdown(10 * time.Second)
// Basic enqueue - specify workflow and queue by name
handle, err := client.Enqueue("task_queue", "processTask", "task-data")
if err != nil {
log.Fatal(err)
}
// Wait for the result
result, err := handle.GetResult()
Enqueue with options:
handle, err := client.Enqueue("task_queue", "processTask", "task-data",
dbos.WithEnqueueWorkflowID("custom-id"),
dbos.WithEnqueueDeduplicationID("unique-id"),
dbos.WithEnqueuePriority(10),
dbos.WithEnqueueTimeout(5*time.Minute),
dbos.WithEnqueueQueuePartitionKey("user-123"),
dbos.WithEnqueueApplicationVersion("2.0.0"),
)
Enqueue options:
WithEnqueueWorkflowID: Custom workflow IDWithEnqueueDeduplicationID: Prevent duplicate enqueuesWithEnqueuePriority: Queue priority (lower = higher priority)WithEnqueueTimeout: Workflow timeoutWithEnqueueQueuePartitionKey: Partition key for partitioned queuesWithEnqueueApplicationVersion: Override application version
The workflow name must match the registered name or custom name set with WithWorkflowName during registration.
Always call client.Shutdown() when done.
Reference: DBOS Client Enqueue