Skip to content

Commit 2e40804

Browse files
JoshVanLmikeeeyaron2
authored
Worklow: add now about start time (dapr#742)
Signed-off-by: joshvanl <me@joshvanl.dev> Co-authored-by: Mike Nguyen <hey@mike.ee> Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
1 parent 22b8ab7 commit 2e40804

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

examples/workflow/main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ func main() {
6464
ctx := context.Background()
6565

6666
// Start workflow test
67+
// Set the start time to the current time to not wait for the workflow to
68+
// "start". This is useful for increasing the throughput of creating
69+
// workflows.
70+
// workflow.WithStartTime(time.Now())
6771
instanceID, err := wfClient.ScheduleNewWorkflow(ctx, "TestWorkflow", workflow.WithInstanceID("a7a4168d-3a1c-41da-8a4f-e7f6d9c718d9"), workflow.WithInput(1))
6872
if err != nil {
6973
log.Fatalf("failed to start workflow: %v", err)

workflow/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ func WithRawInput(input string) api.NewOrchestrationOptions {
6565
return api.WithRawInput(wrapperspb.String(input))
6666
}
6767

68-
// WithStartTime is an option to set the start time when scheduling a new workflow.
68+
// WithStartTime is an option to set the start time when scheduling a new
69+
// workflow. Setting this option will prevent Dapr from "waiting" for the
70+
// Workflow to start, meaning that it can improve workflow creation throughput.
71+
// Meaning setting this value to `time.Now()` can be useful.
6972
func WithStartTime(time time.Time) api.NewOrchestrationOptions {
7073
return api.WithStartTime(time)
7174
}

0 commit comments

Comments
 (0)