dsl

package
v0.0.0-...-94a9b73 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

This sample demonstrates how to implement a DSL workflow. In this sample, we provide 2 sample yaml files each defines a custom workflow that can be processed by this DSL workflow sample code.

Steps to run this sample:

  1. You need a Temporal service running. See README.md for more details.
  2. Run
go run dsl/worker/main.go

to start worker for dsl workflow. 3) Run

go run dsl/starter/main.go

to submit start request for workflow defined in workflow1.yaml file.

Next:

  1. You can run
go run dsl/starter/main.go -dslConfig=dsl/workflow2.yaml

to see the result. 2) You can also write your own yaml config to play with it. 3) You can replace the dummy activities to your own real activities to build real workflow based on this simple DSL workflow.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleDSLWorkflow

func SimpleDSLWorkflow(ctx workflow.Context, dslWorkflow Workflow) ([]byte, error)

SimpleDSLWorkflow workflow definition

Types

type ActivityInvocation

type ActivityInvocation struct {
	Name      string
	Arguments []string
	Result    string
}

ActivityInvocation is used to express invoking an Activity. The Arguments defined expected arguments as input to the Activity, the result specify the name of variable that it will store the result as which can then be used as arguments to subsequent ActivityInvocation.

type Parallel

type Parallel struct {
	Branches []*Statement
}

Parallel can be a collection of Statements that runs in parallel.

type SampleActivities

type SampleActivities struct {
}

func (*SampleActivities) SampleActivity1

func (a *SampleActivities) SampleActivity1(ctx context.Context, input []string) (string, error)

func (*SampleActivities) SampleActivity2

func (a *SampleActivities) SampleActivity2(ctx context.Context, input []string) (string, error)

func (*SampleActivities) SampleActivity3

func (a *SampleActivities) SampleActivity3(ctx context.Context, input []string) (string, error)

func (*SampleActivities) SampleActivity4

func (a *SampleActivities) SampleActivity4(ctx context.Context, input []string) (string, error)

func (*SampleActivities) SampleActivity5

func (a *SampleActivities) SampleActivity5(ctx context.Context, input []string) (string, error)

type Sequence

type Sequence struct {
	Elements []*Statement
}

Sequence consist of a collection of Statements that runs in sequential.

type Statement

type Statement struct {
	Activity *ActivityInvocation
	Sequence *Sequence
	Parallel *Parallel
}

Statement is the building block of dsl workflow. A Statement can be a simple ActivityInvocation or it could be a Sequence or Parallel.

type Workflow

type Workflow struct {
	Variables map[string]string
	Root      Statement
}

Workflow is the type used to express the workflow definition. Variables are a map of valuables. Variables can be used as input to Activity.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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