English | 简体中文
Minimal usage example for client/workflow using grpc protocol
Refer to dtm installation and running
go run main.go
The order of execution can be seen in the log of workflow-grpc as follows.
- TransOut
- TransIn
The entire workflow transaction was executed successfully
A complete example includes following steps:
s := busi.GrpcNewServer()
workflow.InitGrpc(busi.DtmGrpcServer, busi.BusiGrpc, s)
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)
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
}
err = workflow.Execute(wfName, shortuuid.New(), data)