Support Saga in Go SDK

Pretty self-explanatory. There is an open issue about this in Cadence Go SDK as well (and a PR that fell through).

I believe the recommendation is to have an interface as follows (similar to the Java SDK, but with ctx to pass the saga):

sagaCtx := saga.New(ctx, options)
...
saga.addCompensation(sagaCtx, ....)
...
saga.Compensate(sagaCtx)

And utilising Workflow.NewDisconnectedContext behind the scenes to ensure the compensation code continues to execute even after the root context has been cancelled.

I read in another related PR (https://github.com/uber-go/cadence-client/pull/939) that there were no plans on introducing it to the core client (not sure if it still applies), so I’ve taken the liberty of introducing it in a separate repository in case anyone is looking for a solution: https://github.com/Courtsite/temporal-go-helpers

1 Like