Skip to content

direktiv/serverless-workflow-sdk-go

 
 

Repository files navigation

Go SDK for Serverless Workflow

Here you will find all the specification types defined by our Json Schemas, in Go.

Current status of features implemented in the SDK is listed in the table below:

Feature Status
Parse workflow JSON and YAML definitions ✔️
Programmatically build workflow definitions 🚫
Validate workflow definitions (Schema) ✔️
Validate workflow definitions (Integrity) 🚫
Generate workflow diagram (SVG) 🚫

How to use

Run the following command in the root of your Go's project:

$ go get github.com/vorteil/serverless-workflow-sdk-go

Your go.mod file should be updated to add a dependency from the Serverless Workflow specification.

To use the generated types, import the package in your go file like this:

import "github.com/vorteil/serverless-workflow-sdk-go/model"

Then just reference the package in your Go file like myfunction := model.Function{}.

Parsing Serverless Workflow files

Serverless Workflow Specification supports YAML and JSON files for Workflow definitions. To transform such files into a Go data structure, use:

package sw

import (

"github.com/vorteil/serverless-workflow-sdk-go/model"
"github.com/vorteil/serverless-workflow-sdk-go/parser"
)

func ParseWorkflow(filePath string) (*model.Workflow, error) {
	workflow, err := parser.FromFile(filePath)
    if err != nil {
        return nil, err
    } 
    return workflow, nil
} 

The Workflow structure then can be used in your application.

Packages

No packages published

Languages

  • Go 75.9%
  • Shell 22.0%
  • Makefile 2.1%