execution

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ActionNotFoundErr = errors.New("action not found")
View Source
var PackNotFoundErr = errors.New("pack not found")

Functions

func CompleteAction

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

func PostEvent

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

func TakeAction

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

Types

type Action

type Action struct {
	Id         string            `bson:"_id"`
	Name       string            `bson:"name"`
	PackName   string            `bson:"packName"`
	PackLabels map[string]string `bson:"packLabels,omitempty"`
	Input      json.Json         `bson:"input,omitempty"`
	State      State             `bson:"state"`
	States     []State           `bson:"states"`

	CorrelationId string `bson:"correlationId"`
	FlowName      string `bson:"flowName"`
	FlowUUID      string `bson:"flowUUID"`
	StepId        string `bson:"stepId"`

	Context map[string]string `bson:"context,omitempty"`
	Trigger Event             `bson:"trigger"`
	Result  Event             `bson:"result,omitempty"`
	// contains filtered or unexported fields
}

type ActionRepository

type ActionRepository interface {
	Add(action Action) error
	Get(actionId string) (*Action, error)
	Update(action Action) error
	FindNew(pack Pack, name string) (*Action, error)
	FindCorrelated(correlationId string) ([]Action, error)
}

type AuditRepository

type AuditRepository interface {
	Add(action Action) error
	Update(action Action) error
}

type Command

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

type Event

type Event struct {
	Name       string    `json:"event" bson:"name"`
	Pack       Pack      `json:"pack" bson:"pack"`
	Payload    json.Json `json:"payload" bson:"payload,omitempty"`
	CreatedAt  time.Time `json:"createdAt,omitempty" bson:"createdAt,omitempty"`
	ReceivedAt time.Time `json:"receivedAt,omitempty" bson:"receivedAt,omitempty"`
}

type EventDef

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

type Flow

type Flow struct {
	UUID  string `bson:"uuid"`
	Name  string `bson:"name"`
	Steps []Step `bson:"steps,omitempty"`
	// contains filtered or unexported fields
}

func (*Flow) HandleEvent

func (f *Flow) HandleEvent(e Event)

type FlowRepository

type FlowRepository interface {
	GetByAction(a Action) (*Flow, error)
	FindByEvent(e Event) ([]Flow, error)
}

type FlowService

type FlowService interface {
	HandleEvent(e Event)
	HandleAction(a Action)
}

type Pack

type Pack struct {
	Id     string            `bson:"_id"`
	Name   string            `bson:"name"`
	Labels map[string]string `bson:"labels,omitempty"`
}

func (Pack) CompleteAction

func (p Pack) CompleteAction(actionId string, result Event) (*Action, error)

func (Pack) TakeAction

func (p Pack) TakeAction(actionName string) (*Action, error)

func (Pack) UpdateLastSeen

func (p Pack) UpdateLastSeen()

type PackRepository

type PackRepository interface {
	Get(id string) (*Pack, error)
	UpdateLastSeen(id string) error
}

type State

type State struct {
	Value string    `bson:"value"`
	Time  time.Time `bson:"time"`
}

type Step

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

func (Step) Execute

func (s Step) Execute(e Event, parentCtx map[string]string) (*Action, error)

Jump to

Keyboard shortcuts

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