workflow-engine

command module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

workflow-engine

File structure

|--workflow-example
|  |--main.go
|  |--config.json
|  |--workflows
|    |--workflow1
|      |--steps
         |--step1
|          |--step1.go
|        |--step2
|          |--step2.go
|        |--step3
|          |--step3.go
|          |--step4
|        |--step4.go
|      |--trigger.go
|      |--definition.json
|      |--init.go

File content

main.go
package main

import (
	workflowFramework "workflow-engine/engine"
	"workflow-engine/workflow-example/workflows"
	workflow1 "workflow-engine/workflow-example/workflows/workflow1"
)

func main() {
	app := workflowFramework.CreateApp()
	app.RegisterWorkflow(workflow1.Definition, workflow1.Steps, workflow1.Trigger)
	app.RegisterConfig(workflows.ParseConfig)
	app.Start()
}

step1.go
package step1

import (
	"fmt"
	"time"
	"workflow-engine/handler"
)

func Execute(handler handler.Handler) {
	fmt.Println("running step1")
	path := "step1.field1.field2"
	value := "test1"
	handler.FlowData.Set(path, value)
	time.Sleep(5 * time.Second)
}


trigger.go
package workflow1

import (
	workflowFramework "workflow-engine/engine"
)

func TriggerCondition(event workflowFramework.Event) bool {
	return event.Model == "expense" && event.Type == "ADDED"
}

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