47 lines
1020 B
Go
47 lines
1020 B
Go
package rules
|
|
|
|
import (
|
|
"time"
|
|
|
|
"code.tnxs.net/taxnexus/lib/api/devops/devops_models"
|
|
"code.tnxs.net/taxnexus/lib/app"
|
|
"go.temporal.io/sdk/workflow"
|
|
)
|
|
|
|
// NewUserChannelWrapper wraps a contact, account, payment method and a user identifier (app.User)
|
|
type NewUserChannelWrapper struct {
|
|
User devops_models.User
|
|
Principal app.User
|
|
SagaID string
|
|
SagaType string
|
|
}
|
|
|
|
// NewUserWorkflow is a Temporal workflow
|
|
func NewUserWorkflow(ctx workflow.Context, payload *NewUserChannelWrapper) error {
|
|
ctx = workflow.WithActivityOptions(
|
|
ctx,
|
|
workflow.ActivityOptions{
|
|
StartToCloseTimeout: time.Minute,
|
|
})
|
|
err := workflow.ExecuteActivity(ctx,
|
|
StoreUserActivity,
|
|
&app.UserChannelWrapper{
|
|
Obj: payload.User,
|
|
APIKey: payload.Principal.APIKey,
|
|
SagaID: payload.SagaID,
|
|
SagaType: payload.SagaType,
|
|
}).Get(ctx, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
err = workflow.ExecuteActivity(
|
|
ctx,
|
|
NotifyLeadActivity,
|
|
payload,
|
|
).Get(ctx, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|