-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkflows.go
More file actions
54 lines (44 loc) · 1.22 KB
/
workflows.go
File metadata and controls
54 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package main
import (
"time"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)
func LeadCallingWorkflow(ctx workflow.Context, lead Lead) error {
logger := workflow.GetLogger(ctx)
logger.Info("Workflow started", "leadID", lead.ID)
var callID string
var callResult string
// activity options
ao := workflow.ActivityOptions{
StartToCloseTimeout: 5 * time.Second,
RetryPolicy: &temporal.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 4.0,
MaximumInterval: 1 * time.Minute,
MaximumAttempts: 4,
NonRetryableErrorTypes: []string{
"ValidationError",
},
},
}
ctx = workflow.WithActivityOptions(ctx, ao)
err := workflow.ExecuteActivity(ctx, PickLeadActivity, lead).Get(ctx, &callID)
if err != nil {
return err
}
err = workflow.ExecuteActivity(ctx, CallCustomerActivity, lead).Get(ctx, &callID)
if err != nil {
return err
}
workflow.GetSignalChannel(ctx, "call-result").Receive(ctx, &callResult)
err = workflow.ExecuteActivity(ctx, UpdateLeadActivity, lead.ID, callResult).Get(ctx, nil)
if err != nil {
return err
}
err = workflow.ExecuteActivity(ctx, CreateInteractionActivity, lead.ID, callResult).Get(ctx, nil)
if err != nil {
return err
}
return nil
}