README
¶
Recovery Sample
This sample implements a RecoveryWorkflow
which is designed to restart all TripWorkflow
executions which are currently
outstanding and replay all signals from previous run. This is useful where a bad code change is rolled out which
causes workflows to get stuck or state is corrupted.
Steps to run this sample
- Run the following command to start worker
go run recovery/worker/main.go
- Run the following command to start trip workflow
go run recovery/starter/main.go
- Run the following command to query trip workflow
go run recovery/query/main.go
- Run the following command to send signal to trip workflow
go run recovery/signal/main.go -s '{"ID": "Trip1", "Total": 10}'
- Run the following command to start recovery workflow
go run recovery/starter/main.go -w recovery_workflow -wt recoveryworkflow -i '{"Type": "TripWorkflow", "Concurrency": 2}'
Documentation
¶
Index ¶
- Constants
- Variables
- func RecoverExecutions(ctx context.Context, key string, startIndex, batchSize int) error
- func RecoverWorkflow(ctx workflow.Context, params Params) error
- func TripWorkflow(ctx workflow.Context, state UserState) error
- type ClientKey
- type ListOpenExecutionsResult
- type Params
- type RestartParams
- type SignalParams
- type TripEvent
- type UserState
Constants ¶
const ( // TripSignalName is the signal name for trip completion event TripSignalName = "trip_event" // QueryName is the query type name QueryName = "counter" )
Variables ¶
var ( // ErrClientNotFound when client is not found on context ErrClientNotFound = errors.New("failed to retrieve client from context") // ErrExecutionCacheNotFound when executions cache is not found on context ErrExecutionCacheNotFound = errors.New("failed to retrieve cache from context") )
var HostID = "recovery_" + uuid.New()
HostID - Use a new uuid just for demo so we can run 2 host specific activity workers on same machine. In real world case, you would use a hostname or ip address as HostID.
Functions ¶
func RecoverExecutions ¶
func RecoverWorkflow ¶
RecoverWorkflow is the workflow implementation to recover TripWorkflow executions
func TripWorkflow ¶
TripWorkflow to keep track of total trip count for a user It waits on a TripEvent signal and increments a counter on each signal received by this workflow Trip count is managed as workflow state and passed to new run after 10 signals received by each execution
Types ¶
type ListOpenExecutionsResult ¶
ListOpenExecutionsResult is the result returned from listOpenExecutions activity
func ListOpenExecutions ¶
func ListOpenExecutions(ctx context.Context, workflowType string) (*ListOpenExecutionsResult, error)
type RestartParams ¶
type RestartParams struct { Options client.StartWorkflowOptions State UserState }
RestartParams are parameters extracted from StartWorkflowExecution history event
type SignalParams ¶
SignalParams are the parameters extracted from SignalWorkflowExecution history event