workflow-grpc

command
v0.0.0-...-0705590 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 9 Imported by: 0

README

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.

  • TransOut
  • TransIn

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)
For more examples, see dtm-examples

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL