flow

package
v0.0.0-...-3faa8e7 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const SchemaFile = "flow-schema.json"

Variables

View Source
var FlowNotFoundErr = errors.New("flow not found")

Functions

func DeleteFlow

func DeleteFlow(w http.ResponseWriter, r *http.Request)

func GetFlow

func GetFlow(w http.ResponseWriter, r *http.Request)

func GetFlows

func GetFlows(w http.ResponseWriter, r *http.Request)

func PostFlow

func PostFlow(w http.ResponseWriter, r *http.Request)

Types

type Command

type Command struct {
	Name       string            `json:"name" bson:"name"`
	PackName   string            `json:"packName" bson:"packName"`
	PackLabels map[string]string `json:"packLabels,omitempty" bson:"packLabels,omitempty"`
	Input      json.Json         `json:"input" bson:"input"`
}

type Event

type Event struct {
	Name       string            `json:"name" bson:"name"`
	PackName   string            `json:"packName" bson:"packName"`
	PackLabels map[string]string `json:"packLabels,omitempty" bson:"packLabels,omitempty"`
}

type Flow

type Flow struct {
	UUID        string `json:"-" bson:"uuid"`
	Name        string `json:"name" bson:"name"`
	Description string `json:"description,omitempty" bson:"description,omitempty"`
	Steps       []Step `json:"steps,omitempty" bson:"steps,omitempty"`
}

Flow uses two different collections, one contains latest flows (one per name) and the the other is history collection containing all flows that have been added. Because mongo does NOT allow to update `_id` field we have to use custom `uuid` field, so we can update this field in flow collection to make replacing latest flow atomic. This uuid is the same in both collections for the latest flow.

type Repository

type Repository interface {
	Add(flow Flow) error
	Remove(name string) error
	Get(name string) (*Flow, error)
	FindAll() ([]Flow, error)
}

type Step

type Step struct {
	Id        string            `json:"id,omitempty" bson:"id,omitempty"`
	DependsOn []string          `json:"dependsOn,omitempty" bson:"dependsOn,omitempty"`
	Event     Event             `json:"event" bson:"event"`
	Context   map[string]string `json:"context,omitempty" bson:"context,omitempty"`
	Criteria  string            `json:"criteria,omitempty" bson:"criteria,omitempty"`
	Command   Command           `json:"command" bson:"command"`
}

Jump to

Keyboard shortcuts

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