carefull...

v0.1.24 v0.1.24
Vernon Keenan 2021-01-19 17:34:28 -08:00
parent fbd1aeedc8
commit 9ecf742360
2 changed files with 18 additions and 19 deletions

View File

@ -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
} }

View File

@ -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)