Skip to content

Commit

Permalink
run as method
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanos committed Oct 4, 2024
1 parent 3c68ea4 commit eac75d8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions early-return/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ type Transaction struct {
// the initialization in a single round trip, even before the transaction processing completes. The remainder
// of the transaction is then processed asynchronously.
func Workflow(ctx workflow.Context, tx Transaction) error {
return run(ctx, tx)
}

func run(ctx workflow.Context, tx Transaction) error {
logger := workflow.GetLogger(ctx)

if err := workflow.SetUpdateHandler(
ctx,
UpdateName,
tx.ReturnInitResult,
tx.returnInitResult,
); err != nil {
return err
}
Expand Down Expand Up @@ -80,7 +84,7 @@ func Workflow(ctx workflow.Context, tx Transaction) error {
return nil
}

func (tx *Transaction) ReturnInitResult(ctx workflow.Context) error {
func (tx *Transaction) returnInitResult(ctx workflow.Context) error {
if err := workflow.Await(ctx, func() bool { return tx.initDone }); err != nil {
return fmt.Errorf("transaction init cancelled: %w", err)
}
Expand Down

0 comments on commit eac75d8

Please sign in to comment.