Version: v0.0.0-...-821bb50 Latest Latest

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

Go to latest
Published: Jun 29, 2021 License: MIT Imports: 7 Imported by: 0




This section is empty.


View Source
var ErrStatusTransition = errors.New("Invalid graph status transition")

ErrStatusTransition is when an invalid status transition is requested


This section is empty.


type Manager

type Manager struct {
	ActorStorage    storage.ActorStorage
	PipelineStorage storage.PipelineStorage
	Pipelines       []Pipeline

Manager manages the pipelines

func NewManager

func NewManager(
	actorStorage storage.ActorStorage,
	pipelineStorage storage.PipelineStorage,
) *Manager

NewManager returns a Manager

func (*Manager) GetPipeline

func (m *Manager) GetPipeline(id api.UUID) (Pipeline, bool)

GetPipeline load a pipeline from its id

func (*Manager) LookupPipeline

func (m *Manager) LookupPipeline(
	emitter api.Actor, output string, eventtypes []string,
) (*Pipeline, storage.NodeOutputRef, bool)

LookupPipeline returns the matching pipeline for a specific event type

func (*Manager) Query

func (m *Manager) Query(
	name string, version string, activeOnly bool,
) (result []Pipeline)

Query lookup for pipelines matching some criterions

func (*Manager) Save

func (m *Manager) Save(pipeline *Pipeline) (*Pipeline, error)

Save validates and saves a pipeline

func (*Manager) SetStatus

func (m *Manager) SetStatus(pipeline Pipeline, status api.PipelineInfo_Status) error

SetStatus changes a pipeline status

type NodeType

type NodeType int

NodeType is the type of Node

const (
	// EmitterNode is the type of emitter nodes
	EmitterNode NodeType = iota
	// ConsumerNode is the type of consumer nodes
	// WorkerNode is the type of worker nodes

type Path

type Path []storage.Edge

A Path is a list of vertices

func (Path) Clone

func (p Path) Clone() Path

Clone returns a copy of the path with a capacity of +1

func (Path) Contains

func (p Path) Contains(id string) int

Contains returns true if the Path contains the given node

type PathList

type PathList []Path

PathList is a list of Path

func (PathList) ContainsCycle

func (l PathList) ContainsCycle(cycle Path) bool

ContainsCycle returns true if the given cycle is already in the path list

type Pipeline

type Pipeline struct {
	storage.Pipeline `yaml:",inline"`

Pipeline is a single xbus pipeline

func NewPipeline

func NewPipeline(pipeline storage.Pipeline) Pipeline

NewPipeline creates a graph

func (Pipeline) GetDestinations

func (p Pipeline) GetDestinations(output storage.NodeOutputRef) ([]storage.NodeInputRef, error)

GetDestinations returns the inputs on which to send envelope coming from given outputs

func (Pipeline) GetNode

func (p Pipeline) GetNode(id string) (storage.Node, error)

GetNode returns a node from its ID

func (Pipeline) Match

func (p Pipeline) Match(
	emitter api.Actor, output string, eventtypes []string,
) (storage.NodeOutputRef, bool)

Match returns the source input corresponding to the emitter & eventtypes and true if it exists, empty value and false if not

type ValidationError

type ValidationError struct {
	Code      ValidationErrorCode
	NodeID    string // The node having an error if relevant
	InputRef  storage.NodeInputRef
	OutputRef storage.NodeOutputRef
	Edge      storage.Edge
	Path      Path // The path having an error if relevant
	Actor     string
	Role      string
	Args      []string // extra arguments for error formatting

ValidationError is a detailed graph validation error

func ConsumerActorIDsForbidden

func ConsumerActorIDsForbidden(nodeID string) ValidationError

ConsumerActorIDsForbidden returns a ErrConsumerActorIDsForbidden

func ConsumerHasMultipleInput

func ConsumerHasMultipleInput(nodeID string) ValidationError

ConsumerHasMultipleInput returns a ErrConsumerHasMultipleInput

func ConsumerHasNoInput

func ConsumerHasNoInput(nodeID string) ValidationError

ConsumerHasNoInput returns a ErrConsumerHasNoInput

func ConsumerHasOutput

func ConsumerHasOutput(nodeID string) ValidationError

ConsumerHasOutput returns a ErrConsumerHasOutput

func ConsumerMustHave1RoleOrActors

func ConsumerMustHave1RoleOrActors(nodeID string) ValidationError

ConsumerMustHave1RoleOrActors returns a ErrConsumerMustHave1RoleOrActors

func CycleError

func CycleError(path Path) ValidationError

CycleError returns a ErrGraphCycle error

func DisconnectedGraphError

func DisconnectedGraphError() ValidationError

DisconnectedGraphError returns a ErrDisconnectedGraph error

func DisconnectedInputError

func DisconnectedInputError(inputRef storage.NodeInputRef) ValidationError

DisconnectedInputError returns a ErrDisconnectedInput error

func DisconnectedOutputError

func DisconnectedOutputError(outputRef storage.NodeOutputRef) ValidationError

DisconnectedOutputError returns a ErrDisconnectedOutput error

func DuplicateNodeIDError

func DuplicateNodeIDError(nodeID string) ValidationError

DuplicateNodeIDError returns a ErrDuplicateNodeID

func EdgeInvalidFromError

func EdgeInvalidFromError(edge storage.Edge) ValidationError

EdgeInvalidFromError returns a ErrEdgeInvalidFrom error

func EdgeInvalidToError

func EdgeInvalidToError(edge storage.Edge) ValidationError

EdgeInvalidToError returns a ErrEdgeInvalidTo error

func EmitterHasInput

func EmitterHasInput(nodeID string) ValidationError

EmitterHasInput returns a ErrEmitterHasInput

func EmitterHasMultipleOutput

func EmitterHasMultipleOutput(nodeID string) ValidationError

EmitterHasMultipleOutput returns a ErrEmitterHasMultipleOutput

func EmitterHasNoOutput

func EmitterHasNoOutput(nodeID string) ValidationError

EmitterHasNoOutput returns a ErrEmitterHasNoOutput

func ExtraEmitterError

func ExtraEmitterError(nodeID string) ValidationError

ExtraEmitterError returns a ErrExtraEmitter error

func InvalidNodeID

func InvalidNodeID(nodeID string) ValidationError

InvalidNodeID returns a ErrInvalidNodeID

func MissingConsumerError

func MissingConsumerError() ValidationError

MissingConsumerError returns a ErrMissingConsumer error

func MissingEmitterError

func MissingEmitterError() ValidationError

MissingEmitterError returns a ErrMissingEmitter error

func MissingSourceMatch

func MissingSourceMatch(nodeID string) ValidationError

MissingSourceMatch returns a ErrMissingSourceMatch

func NoActorForRoleError

func NoActorForRoleError(nodeID string, role string) ValidationError

NoActorForRoleError returns a ErrNoActorForRole error

func RequestorAndConsumer

func RequestorAndConsumer() ValidationError

RequestorAndConsumer returns a ErrRequestorAndConsumer error

func RequestorAndEmitter

func RequestorAndEmitter() ValidationError

RequestorAndEmitter returns a ErrRequestorAndEmitter error

func RequestorInputMustBeResponse

func RequestorInputMustBeResponse(nodeID string) ValidationError

RequestorInputMustBeResponse returns a ErrRequestorInputMustBeResponse

func RequestorOutputMustBeRequest

func RequestorOutputMustBeRequest(nodeID string) ValidationError

RequestorOutputMustBeRequest returns a ErrRequestorOutputMustBeRequest

func RoleBroadcastUnsetError

func RoleBroadcastUnsetError(nodeID string) ValidationError

RoleBroadcastUnsetError returns a ErrRoleBroadcastUnset error

func SinkIsNotConsumerError

func SinkIsNotConsumerError(nodeID string) ValidationError

SinkIsNotConsumerError returns a ErrSinkIsNotConsumer error

func SourceIsNotEmitterError

func SourceIsNotEmitterError(nodeID string) ValidationError

SourceIsNotEmitterError returns a ErrSourceIsNotEmitter error

func SourceMatchInvalidEventType

func SourceMatchInvalidEventType(nodeID string, eventType string) ValidationError

SourceMatchInvalidEventType returns a ErrSourceMatchInvalidEventType

func TooManyRolesError

func TooManyRolesError(nodeID string) ValidationError

TooManyRolesError returns a ErrTooManyRoles error

func UnknownActorError

func UnknownActorError(nodeID string, actor string) ValidationError

UnknownActorError returns a ErrUnknownActor error

func (ValidationError) Error

func (v ValidationError) Error() string

type ValidationErrorCode

type ValidationErrorCode int

ValidationErrorCode is a validation error code

const (
	// ErrMissingEmitter is when a graph has no emitter
	ErrMissingEmitter ValidationErrorCode = iota
	// ErrMissingConsumer is when a graph has no consumer
	// ErrRequestorAndEmitter is when a graph has a requestor and an emitter
	// ErrRequestorAndConsumer is when a graph has a requestor and a consumer
	// ErrExtraEmitter is when a graph has more than one emitter
	// ErrMissingSourceMatch - a emitter has no sourcematch
	// ErrSourceMatchInvalidEventType - an eventtype is invalid
	// ErrEmitterHasNoOutput is when a emitter node has no output
	// ErrEmitterHasMultipleOutput is when a emiiter node has multiple output
	// ErrEmitterHasInput - a emitter node has some input
	// ErrRequestorOutputMustBeRequest is when a requestor emitter (with one
	// input) has an output not named "request"
	// ErrRequestorInputMustBeResponse is when a requestor emitter (with one
	// input) has an input not named "response"
	// ErrConsumerHasNoInput - a consumer has no input
	// ErrConsumerHasMultipleInput - a consumer has multiple input
	// ErrConsumerHasOutput - a consumer has an output
	// ErrConsumerMustHave1RoleOrActors - the consumer node must have one role or have 'actors' defined
	// ErrConsumerActorIDsForbidden - a consummer cannot have 'actorids' defined
	// ErrDisconnectedInput is when an input is not connected by any edge
	// ErrDisconnectedOutput is when an ouput is not connected by any edge
	// ErrEdgeInvalidFrom is when the origin of an edge does not exist
	// ErrEdgeInvalidTo is when the target of an edge does not exist
	// ErrCycle is when the graph has a cycle
	// ErrDisconnectedGraph is when the graph is not connected
	// ErrSourceIsNotEmitter is when a source node is not an emitter
	// ErrSinkIsNotConsumer is when a sink node is not a consumer

	// ErrInvalidNodeID is when a node ID is empty or contains any non [a-zA-Z0-9_\-] character
	// ErrDuplicateNodeID is when two nodes have the same ID

	// ErrUnknownActor is when a node actorID item does not exist
	// ErrNoActorForRole is when a role matches no actor

	// ErrTooManyRoles is when a node has more than 1 role
	// ErrRoleBroadcastUnset is when a role is set but rolebroadcast is not (it should)

type ValidationErrorList

type ValidationErrorList []ValidationError

ValidationErrorList is a list or validation errors

func (*ValidationErrorList) Add

Add appends an error to the list

func (ValidationErrorList) Error

func (l ValidationErrorList) Error() string

func (ValidationErrorList) Messages

func (l ValidationErrorList) Messages() []string

Messages returns the errors as a list of messages

type Validator

type Validator struct {
	Graph storage.Graph
	// contains filtered or unexported fields

Validator validates a graph consistency

func NewValidator

func NewValidator(graph storage.Graph) Validator

NewValidator crates a Validator

func (*Validator) Validate

func (v *Validator) Validate() (errors ValidationErrorList)

Validate enforce the graph is consistent.

func (*Validator) ValidateActors

func (v *Validator) ValidateActors(actorStorage storage.ActorStorage) ValidationErrorList

ValidateActors returns true if the graph actors & roles actually exists If not, returns false and a list of ValidationError

Jump to

Keyboard shortcuts

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