35 lines
735 B
Go
35 lines
735 B
Go
|
package rules
|
||
|
|
||
|
import (
|
||
|
"time"
|
||
|
|
||
|
"code.tnxs.net/taxnexus/lib/app"
|
||
|
"go.temporal.io/sdk/workflow"
|
||
|
)
|
||
|
|
||
|
// NewLeadWorkflow is a workflow
|
||
|
func NewLeadWorkflow(ctx workflow.Context, payload *app.LeadChannelWrapper) error {
|
||
|
ctx = workflow.WithActivityOptions(ctx, workflow.ActivityOptions{
|
||
|
StartToCloseTimeout: time.Minute,
|
||
|
})
|
||
|
err := workflow.ExecuteActivity(ctx,
|
||
|
StoreLeadActivity,
|
||
|
&app.LeadChannelWrapper{
|
||
|
Obj: payload.Obj,
|
||
|
Principal: payload.Principal,
|
||
|
}).Get(ctx, nil)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
err = workflow.ExecuteActivity(ctx,
|
||
|
NotifyLeadActivity,
|
||
|
&app.LeadChannelWrapper{
|
||
|
Obj: payload.Obj,
|
||
|
Principal: payload.Principal,
|
||
|
}).Get(ctx, nil)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
return nil
|
||
|
}
|