engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthValidate

func AuthValidate(r *http.Request, auth *Authorizer) error

AuthValidate : to validate incoming request

func CORSValidate

func CORSValidate(r *http.Request, w http.ResponseWriter, cors map[string]interface{}) error

CORSValidate : to validate the cors policy for the workflow

func SetConfig

func SetConfig(port int, prefix string)

SetConfig : running config for workflow

func Validate

func Validate(r *http.Request, w http.ResponseWriter, wf *Workflow) error

Validate : Validating access request

Types

type APIStep

type APIStep struct {
	Endpoint       string            `json:"endpoint" yaml:"endpoint"`
	Method         string            `json:"method" yaml:"method"`
	IncludeHeaders bool              `json:"include-headers" yaml:"include-headers"`
	CustomHeaders  map[string]string `json:"custom-headers" yaml:"custom-headers"`
	Payload        interface{}       `json:"payload" yaml:"payload"`
}

APIStep - properties explicit to logic type step

func (APIStep) Execute

func (api APIStep) Execute(wf *Workflow, headers map[string][]string, queryParams queryParams, userContext map[string]interface{}) (interface{}, error)

type Authorizer

type Authorizer struct {
	Type    string `json:"type" yaml:"type"`
	AKey    string `json:"key" yaml:"key"`
	Input   string `json:"input" yaml:"input"`
	ExePath string `json:"exe-path" yaml:"exe-path"`
	Handler string `json:"handler" yaml:"handler"`
}

Authorizer - To specify authorization method for the respective workflow

type CORS

type CORS struct {
	AllowOrigin  string `json:"allow-origin" yaml:"allow-origin" default:"*"`
	AllowMethods string `json:"allow-methods" yaml:"allow-methods" default:"*"`
	AllowHeaders string `json:"allow-headers" yaml:"allow-headers" default:"*"`
	MaxAge       int64  `json:"maxage" yaml:"maxage"`
}

CORS - properties for the access control to workflow

type Config

type Config struct {
	Port   int
	Prefix string
}

func GetEngConfig

func GetEngConfig() *Config

GetConfig : get existing config

type ExecuteStep

type ExecuteStep interface {
	Execute(*Workflow, map[string][]string, queryParams, map[string]interface{}) (interface{}, error)
}

type JSONData

type JSONData struct {
	// contains filtered or unexported fields
}

type JSONData struct{}

type LogicStep

type LogicStep struct {
	Runtime constants.Runtime `json:"runtime" yaml:"runtime"`
	ExePath string            `json:"exe-path" yaml:"exe-path"`
	Handler string            `json:"handler" yaml:"handler"`
	Params  interface{}       `json:"params" yaml:"params"`
}

LogicStep - properties explicit to logic type step

func (LogicStep) Execute

func (l LogicStep) Execute(wf *Workflow, headers map[string][]string, queryParams queryParams, userContext map[string]interface{}) (interface{}, error)

Execute : executing the logic function

type PrimaryKey

type PrimaryKey struct {
	PKey  string `json:"key" yaml:"key"`
	Input string `json:"input" yaml:"input"`
}

PrimaryKey - Unique key to identify a single instance

type Resp

type Resp struct {
	// contains filtered or unexported fields
}

type Step

type Step struct {
	LogicStep     `yaml:",inline"`
	APIStep       `yaml:",inline"`
	Name          string             `json:"name" yaml:"name"`
	ID            string             `json:"id" yaml:"id"`
	Type          constants.StepType `json:"type" yaml:"type"`
	Async         bool               `json:"async" yaml:"async"`
	Authorize     bool               `json:"authorize" yaml:"authorize"`
	Delay         string             `json:"delay" yaml:"delay"`
	Timeout       string             `json:"timeout" yaml:"timeout"`
	NextStep      string             `json:"next-step" yaml:"next-step"`
	Users         []string           `json:"users" yaml:"users"`
	Break         bool               `json:"break" yaml:"break"`
	Error         *StepError         `json:"on-error" yaml:"on-error"`
	PreCondition  interface{}        `json:"pre-condition" yaml:"pre-condition"`
	PostCondition interface{}        `json:"post-condition" yaml:"post-condition"`
}

Step - It defines a single step

type StepError

type StepError struct {
	Retry bool   `json:"retry" yaml:"retry"`
	Goto  string `json:"goto" yaml:"goto"`
}

StepError - properties defined for step error

type Workflow

type Workflow struct {
	Name       string                 `json:"name" yaml:"name"`
	ID         string                 `json:"id" yaml:"id"`
	Version    string                 `json:"version" yaml:"version"`
	PrimaryKey []PrimaryKey           `json:"primary-key" yaml:"primary-key"`
	Authorizer *Authorizer            `json:"authorizer" yaml:"authorizer"`
	CORS       map[string]interface{} `json:"cors" yaml:"cors"`
	Steps      []Step                 `json:"steps" yaml:"steps"`
}

Workflow - Structure of workflow configuration

func (*Workflow) Run

func (wf *Workflow) Run(ctx context.Context, headers map[string][]string, queryParams map[string][]string, body interface{}) (interface{}, error)

Running the workflow

Jump to

Keyboard shortcuts

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