directive

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

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

InputTypeRequest and others represent consts for Directives.

Variables

View Source
var (
	ErrQueryTypeUnknown = errors.New("unable to determine query type")
	ErrDBTypeUnknown    = errors.New("unable to determine query's database type")
)

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 Connections added in v0.3.1

type Connections struct {
	NATS     *NATSConnection  `yaml:"nats,omitempty" json:"nats,omitempty"`
	Kafka    *KafkaConnection `yaml:"kafka,omitempty" json:"kafka,omitempty"`
	Database *DBConnection    `yaml:"database,omitempty" json:"database,omitempty"`
	Redis    *RedisConnection `yaml:"redis,omitempty" json:"redis,omitempty"`
}

Connections describes connections.

type DBConnection added in v0.4.0

type DBConnection struct {
	Type             string `yaml:"type" json:"type"`
	ConnectionString string `yaml:"connectionString" json:"connectionString"`
}

func (*DBConnection) ToRCAPConfig added in v0.4.0

func (d *DBConnection) ToRCAPConfig(queries []DBQuery) (*rcap.DatabaseConfig, error)

type DBQuery added in v0.4.0

type DBQuery struct {
	Type     string `yaml:"type,omitempty" json:"type,omitempty"`
	Name     string `yaml:"name" json:"name"`
	VarCount int    `yaml:"varCount,omitempty" json:"varCount,omitempty"`
	Query    string `yaml:"query" json:"query"`
}

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"`
	Queries        []DBQuery              `yaml:"queries,omitempty" json:"queries,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() (err error)

Validate validates a directive

type Handler

type Handler struct {
	Input     Input                   `yaml:"input,inline" json:"input"`
	Steps     []executable.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 KafkaConnection added in v0.4.0

type KafkaConnection struct {
	BrokerAddress string `yaml:"brokerAddress" json:"brokerAddress"`
}

KafkaConnection describes a connection to a Kafka broker.

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 RedisConnection added in v0.4.0

type RedisConnection struct {
	ServerAddress string `yaml:"serverAddress" json:"serverAddress"`
	Username      string `yaml:"username" json:"username"`
	Password      string `yaml:"password" json:"password"`
}

RedisConnection describes a connection to a Redis cache.

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"`
	TokenHash    []byte                   `yaml:"-" json:"-"`
}

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.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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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