Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.3 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.3 KB

English | 简体中文

workflow-http

Minimal usage example for client/workflow using http 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-http as follows.

  • TransOut
  • TransIn

The entire workflow transaction was executed successfully

Steps

A complete example includes following steps:

Init Workflow

	app.POST(qsBusiAPI+"/workflowResume", func(ctx *gin.Context) {
		log.Printf("workflowResume")
		data, err := ioutil.ReadAll(ctx.Request.Body)
		logger.FatalIfError(err)
		workflow.ExecuteByQS(ctx.Request.URL.Query(), data)
	})

	workflow.InitHTTP(dtmServer, qsBusi+"/workflowResume")

Register a Workflow

	wfName := "workflow-http"
	err := workflow.Register(wfName, func(wf *workflow.Workflow, data []byte) error {
	// ...
		_, err = wf.NewBranch().NewRequest().SetBody(req).Post(qsBusi + "/TransOut")
	// http request using wf.NewRequest() will be automaticly be intercepted and recorded
	}

Execute a Workflow

	err = workflow.Execute(wfName, shortuuid.New(), data)

For more examples, see dtm-examples