directive

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InputTypeRequest  = "request"
	InputTypeStream   = "stream"
	InputSourceServer = "server"
	InputSourceNATS   = "nats"
)

InputTypeRequest and others represent consts for Directives

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication added in v0.3.1

type Authentication struct {
	Domains map[string]rcap.AuthHeader `yaml:"domains,omitempty" json:"domains,omitempty"`
}

type CallableFn

type CallableFn struct {
	Fn    string            `yaml:"fn,omitempty" json:"fn,omitempty"`
	As    string            `yaml:"as,omitempty" json:"as,omitempty"`
	With  map[string]string `yaml:"with,omitempty" json:"with,omitempty"`
	OnErr *FnOnErr          `yaml:"onErr,omitempty" json:"onErr,omitempty"`
	FQFN  string            `yaml:"-" json:"fqfn"` // calculated during Validate
}

CallableFn is a fn along with its "variable name" and "args"

type Connections added in v0.3.1

type Connections struct {
	NATS *NATSConnection `yaml:"nats,omitempty" json:"nats,omitempty"`
}

Connections describes connections

type Directive

type Directive struct {
	Identifier     string                 `yaml:"identifier" json:"identifier"`
	AppVersion     string                 `yaml:"appVersion" json:"appVersion"`
	AtmoVersion    string                 `yaml:"atmoVersion" json:"atmoVersion"`
	Headless       bool                   `yaml:"headless,omitempty" json:"headless,omitempty"`
	Connections    *Connections           `yaml:"connections,omitempty" json:"connections,omitempty"`
	Authentication *Authentication        `yaml:"authentication,omitempty" json:"authentication,omitempty"`
	Capabilities   *rcap.CapabilityConfig `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`
	Handlers       []Handler              `yaml:"handlers,omitempty" json:"handlers,omitempty"`
	Schedules      []Schedule             `yaml:"schedules,omitempty" json:"schedules,omitempty"`

	// Runnables is populated by subo, never by the user
	Runnables []Runnable `yaml:"runnables" json:"runnables"`
}

Directive describes a set of functions and a set of handlers that take an input, and compose a set of functions to handle it

func (*Directive) FindRunnable added in v0.2.3

func (d *Directive) FindRunnable(name string) *Runnable

func (*Directive) Marshal

func (d *Directive) Marshal() ([]byte, error)

Marshal outputs the YAML bytes of the Directive

func (*Directive) Unmarshal

func (d *Directive) Unmarshal(in []byte) error

Unmarshal unmarshals YAML bytes into a Directive struct it also calculates a map of FQFNs for later use

func (*Directive) Validate

func (d *Directive) Validate() error

Validate validates a directive

type Executable

type Executable struct {
	CallableFn `yaml:"callableFn,inline" json:"callableFn"`
	Group      []CallableFn `yaml:"group,omitempty" json:"group,omitempty"`
	ForEach    *ForEach     `yaml:"forEach,omitempty" json:"forEach,omitempty"`
}

Executable represents an executable step in a handler

func (*Executable) IsFn

func (e *Executable) IsFn() bool

IsFn returns true if the executable is a group

func (*Executable) IsForEach

func (e *Executable) IsForEach() bool

IsForEach returns true if the exectuable is a ForEach

func (*Executable) IsGroup

func (e *Executable) IsGroup() bool

IsGroup returns true if the executable is a group

type FnOnErr

type FnOnErr struct {
	Code  map[int]string `yaml:"code,omitempty" json:"code,omitempty"`
	Any   string         `yaml:"any,omitempty" json:"any,omitempty"`
	Other string         `yaml:"other,omitempty" json:"other,omitempty"`
}

FnOnErr describes how to handle an error from a function call

type ForEach

type ForEach struct {
	In         string     `yaml:"in" json:"in"`
	Fn         string     `yaml:"fn" json:"fn"`
	As         string     `yaml:"as" json:"as"`
	OnErr      *FnOnErr   `yaml:"onErr,omitempty" json:"onErr,omitempty"`
	CallableFn CallableFn `yaml:"-" json:"callableFn"` // calculated during Validate
}

ForEach describes a forEach operator

type Handler

type Handler struct {
	Input     Input        `yaml:"input,inline" json:"input"`
	Steps     []Executable `yaml:"steps" json:"steps"`
	Response  string       `yaml:"response,omitempty" json:"response,omitempty"`
	RespondTo string       `yaml:"respondTo,omitempty" json:"respondTo,omitempty"`
}

Handler represents the mapping between an input and a composition of functions

type Input

type Input struct {
	Type     string `yaml:"type" json:"type"`
	Source   string `yaml:"source,omitempty" json:"source,omitempty"`
	Method   string `yaml:"method" json:"method"`
	Resource string `yaml:"resource" json:"resource"`
}

Input represents an input source

type NATSConnection added in v0.3.1

type NATSConnection struct {
	ServerAddress string `yaml:"serverAddress" json:"serverAddress"`
}

NATSConnection describes a connection to a NATS server

type Runnable

type Runnable struct {
	Name         string                   `yaml:"name" json:"name"`
	Namespace    string                   `yaml:"namespace" json:"namespace"`
	Lang         string                   `yaml:"lang" json:"lang"`
	Version      string                   `yaml:"version" json:"version"`
	DraftVersion string                   `yaml:"draftVersion,omitempty" json:"draftVersion,omitempty"`
	APIVersion   string                   `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
	FQFN         string                   `yaml:"fqfn,omitempty" json:"fqfn,omitempty"`
	FQFNURI      string                   `yaml:"fqfnUri" json:"fqfnURI,omitempty"`
	ModuleRef    *moduleref.WasmModuleRef `yaml:"-" json:"moduleRef,omitempty"`
}

Runnable is the structure of a .runnable.yaml file

type Schedule

type Schedule struct {
	Name  string            `yaml:"name" json:"name"`
	Every ScheduleEvery     `yaml:"every" json:"every"`
	State map[string]string `yaml:"state,omitempty" json:"state,omitempty"`
	Steps []Executable      `yaml:"steps" json:"steps"`
}

Schedule represents the mapping between an input and a composition of functions

func (*Schedule) NumberOfSeconds

func (s *Schedule) NumberOfSeconds() int

NumberOfSeconds calculates the total time in seconds for the schedule's 'every' value

type ScheduleEvery

type ScheduleEvery struct {
	Seconds int `yaml:"seconds,omitempty" json:"seconds,omitempty"`
	Minutes int `yaml:"minutes,omitempty" json:"minutes,omitempty"`
	Hours   int `yaml:"hours,omitempty" json:"hours,omitempty"`
	Days    int `yaml:"days,omitempty" json:"days,omitempty"`
}

ScheduleEvery represents the 'every' value for a schedule

Jump to

Keyboard shortcuts

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