parent
fbd1aeedc8
commit
9ecf742360
|
@ -4,6 +4,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"code.tnxs.net/taxnexus/lib/app"
|
"code.tnxs.net/taxnexus/lib/app"
|
||||||
|
"go.temporal.io/sdk/temporal"
|
||||||
temporal_workflow "go.temporal.io/sdk/workflow"
|
temporal_workflow "go.temporal.io/sdk/workflow"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ type NewLeadWorkflowWrapper struct {
|
||||||
|
|
||||||
// NewLeadWorkflow is a Temporal workflow
|
// NewLeadWorkflow is a Temporal workflow
|
||||||
func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) error { //nolint:gocritic // don't care
|
func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) error { //nolint:gocritic // don't care
|
||||||
obj := app.LeadActivityWrapper{
|
transferDetails := app.LeadActivityWrapper{
|
||||||
// Address: w.Address,
|
// Address: w.Address,
|
||||||
Company: w.Company,
|
Company: w.Company,
|
||||||
Description: w.Description,
|
Description: w.Description,
|
||||||
|
@ -62,27 +63,24 @@ func NewLeadWorkflow(ctx temporal_workflow.Context, w NewLeadWorkflowWrapper) er
|
||||||
UTMTerm: w.UTMTerm,
|
UTMTerm: w.UTMTerm,
|
||||||
Website: w.Website,
|
Website: w.Website,
|
||||||
}
|
}
|
||||||
ctx = temporal_workflow.
|
retryPolicy := &temporal.RetryPolicy{
|
||||||
WithActivityOptions(
|
InitialInterval: time.Second,
|
||||||
ctx,
|
MaximumInterval: time.Minute,
|
||||||
temporal_workflow.ActivityOptions{
|
MaximumAttempts: maxAttempts,
|
||||||
StartToCloseTimeout: time.Minute,
|
}
|
||||||
})
|
options := temporal_workflow.ActivityOptions{
|
||||||
err := temporal_workflow.
|
// Timeout options specify when to automatically timeout Actvitivy functions.
|
||||||
ExecuteActivity(
|
StartToCloseTimeout: time.Minute,
|
||||||
ctx,
|
// Optionally provide a customized RetryPolicy.
|
||||||
StoreLeadActivity,
|
// Temporal retries failures by default, this is just an example.
|
||||||
obj,
|
RetryPolicy: retryPolicy,
|
||||||
).Get(ctx, nil)
|
}
|
||||||
|
ctx = temporal_workflow.WithActivityOptions(ctx, options)
|
||||||
|
err := temporal_workflow.ExecuteActivity(ctx, StoreLeadActivity, transferDetails).Get(ctx, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = temporal_workflow.
|
err = temporal_workflow.ExecuteActivity(ctx, NotifyLeadActivity, transferDetails).Get(ctx, nil)
|
||||||
ExecuteActivity(
|
|
||||||
ctx,
|
|
||||||
NotifyLeadActivity,
|
|
||||||
obj,
|
|
||||||
).Get(ctx, nil)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ const getTimeout = 6 * time.Minute
|
||||||
|
|
||||||
// const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
// const dateTimeFormat = "2006-01-02T15:04:05-0800"
|
||||||
const postTimeout = 6 * time.Minute
|
const postTimeout = 6 * time.Minute
|
||||||
|
const maxAttempts = 50
|
||||||
|
|
||||||
var sugar = logger.New(zapcore.InfoLevel)
|
var sugar = logger.New(zapcore.InfoLevel)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue