English | 简体中文
workflow-grpc
Minimal usage example for client/workflow using grpc protocol
Quick start
Installing and running dtm
Refer to dtm installation and running
Startup example
go run main.go
Output
The order of execution can be seen in the log of workflow-grpc as follows.
The entire workflow transaction was executed successfully
Steps
A complete example includes following steps:
Init Workflow
s := busi.GrpcNewServer()
workflow.InitGrpc(busi.DtmGrpcServer, busi.BusiGrpc, s)
Add Workflow Interceptor
Workflow will automaticly intercept gRPC call, and record the progresses.
conn1, err := grpc.Dial(busi.BusiGrpc, nossl, grpc.WithUnaryInterceptor(workflow.Interceptor))
// check err
busiCli = busi.NewBusiClient(conn1)
Register a Workflow
wfName := "workflow-grpc"
err = workflow.Register(wfName, func(wf *workflow.Workflow, data []byte) error {
// ...
_, err = busiCli.TransOut(wf.Context, &req)
// grpc call should use clients with workflow's interceptor, and workflow's Context
}
Execute a Workflow
err = workflow.Execute(wfName, shortuuid.New(), data)