-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkflow.go
37 lines (30 loc) · 962 Bytes
/
workflow.go
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
package stepcitemporal
import (
"fmt"
"time"
"go.temporal.io/sdk/temporal"
"go.temporal.io/sdk/workflow"
)
func StepCIWorkflow(ctx workflow.Context, input WorkflowInput) (string, error) {
retrypolicy := &temporal.RetryPolicy{
InitialInterval: time.Second,
BackoffCoefficient: 2.0,
MaximumInterval: 100 * time.Second,
MaximumAttempts: 5,
}
ao := workflow.ActivityOptions{
StartToCloseTimeout: time.Minute * 10,
RetryPolicy: retrypolicy,
}
ctx = workflow.WithActivityOptions(ctx, ao)
var result string
err := workflow.ExecuteActivity(ctx, RunStepCI, input.StepCIPath).Get(ctx, &result)
if err != nil {
return "", fmt.Errorf("error runnig stepCI: %v", err)
}
err = workflow.ExecuteActivity(ctx, SendEmail, input.EmailAddress, "StepCI Succeeded").Get(ctx, nil)
if err != nil {
return "", fmt.Errorf("error sending email: %v", err)
}
return fmt.Sprintf("Success message sent to %s", input.EmailAddress), nil
}