tenant

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: Apache-2.0 Imports: 10 Imported by: 13

Documentation

Index

Constants

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

InputTypeRequest and others represent consts for the tenantConfig.

View Source
const (
	ConnectionTypeNATS     = "nats"
	ConnectionTypeKafka    = "kafka"
	ConnectionTypeRedis    = "redis"
	ConnectionTypeMySQL    = "mysql"
	ConnectionTypePostgres = "postgres"
)

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

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

type Config

type Config struct {
	Identifier       string            `yaml:"identifier" json:"identifier"`
	SpecVersion      int               `yaml:"specVersion" json:"specVersion"`
	TenantVersion    int64             `yaml:"tenantVersion" json:"tenantVersion"`
	DefaultNamespace NamespaceConfig   `yaml:"defaultNamespace" json:"defaultNamespace"`
	Namespaces       []NamespaceConfig `yaml:"namespaces" json:"namespaces"`

	// Modules is a union of all consituent namespace modules
	Modules []Module `yaml:"modules" json:"modules"`
}

Config describes a tenant and its related config

func (*Config) FQMNForFunc

func (c *Config) FQMNForFunc(namespace, fn, ref string) (string, error)

func (*Config) FindModule

func (c *Config) FindModule(name string) (*Module, error)

func (*Config) Marshal

func (c *Config) Marshal() ([]byte, error)

Marshal outputs the JSON bytes of the config.

func (*Config) Unmarshal

func (c *Config) Unmarshal(in []byte) error

Unmarshal unmarshals JSON bytes into a TenantConfig struct it also calculates a map of FQMNs for later use.

func (*Config) UnmarshalYaml

func (c *Config) UnmarshalYaml(in []byte) error

UnmarshalYaml unmarshals YAML bytes into a TenantConfig struct it also calculates a map of FQMNs for later use.

func (*Config) Validate

func (c *Config) Validate() (err error)

Validate validates a Config

type Connection

type Connection struct {
	Type   string            `yaml:"type" json:"type"`
	Name   string            `yaml:"name" json:"name"`
	Config map[string]string `yaml:"config" json:"config"`
}

Connection describes a connection to an external resource

type ConnectionConfig

type ConnectionConfig interface {
	Validate() error
}

ConnectionConfig is an interface that defines a connection configuration

type DBConfig

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

func DBConfigFromMap

func DBConfigFromMap(orig map[string]string) *DBConfig

DBConfigFromMap returns a DB config from a map

func (*DBConfig) ToRCAPConfig

func (d *DBConfig) ToRCAPConfig(queries []DBQuery) (*capabilities.DatabaseConfig, error)

func (*DBConfig) Validate

func (d *DBConfig) Validate() error

type DBQuery

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 KafkaConfig

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

KafkaConfig describes a connection to a Kafka broker.

func KafkaConfigFromMap

func KafkaConfigFromMap(orig map[string]string) *KafkaConfig

KafkaConfigFromMap returns a NATS config from a map

func (*KafkaConfig) Validate

func (k *KafkaConfig) Validate() error

type Module

type Module struct {
	Name       string           `yaml:"name" json:"name"`
	Namespace  string           `yaml:"namespace" json:"namespace"`
	Lang       string           `yaml:"lang" json:"lang"`
	Ref        string           `yaml:"ref" json:"ref"`
	DraftRef   string           `yaml:"draftRef,omitempty" json:"draftRef,omitempty"`
	APIVersion string           `yaml:"apiVersion,omitempty" json:"apiVersion,omitempty"`
	FQMN       string           `yaml:"fqmn,omitempty" json:"fqmn,omitempty"`
	URI        string           `yaml:"uri" json:"uri,omitempty"`
	Revisions  []ModuleRevision `yaml:"revisions" json:"revisions"`
	WasmRef    *WasmModuleRef   `yaml:"-" json:"wasmRef,omitempty"`
	TokenHash  []byte           `yaml:"-" json:"-"`
}

Module is the structure of a .Module.yaml file.

type ModuleRevision

type ModuleRevision struct {
	Ref string `json:"ref"`
}

ModuleRevision is a revision of a module

type NATSConfig

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

NATSConfig describes a connection to a NATS server.

func NATSConfigFromMap

func NATSConfigFromMap(orig map[string]string) *NATSConfig

NATSConfigFromMap returns a Kafka config from a map

func (*NATSConfig) Validate

func (n *NATSConfig) Validate() error

type NamespaceConfig

type NamespaceConfig struct {
	Name           string                         `yaml:"name" json:"name"`
	Workflows      []Workflow                     `yaml:"workflows,omitempty" json:"workflows,omitempty"`
	Queries        []DBQuery                      `yaml:"queries,omitempty" json:"queries,omitempty"`
	Capabilities   *capabilities.CapabilityConfig `yaml:"capabilities,omitempty" json:"capabilities,omitempty"`
	Connections    []Connection                   `yaml:"connections,omitempty" json:"connections,omitempty"`
	Authentication *Authentication                `yaml:"authentication,omitempty" json:"authentication,omitempty"`

	// Modules is populated by subo, never by the user.
	Modules []Module `yaml:"modules" json:"modules"`
}

NamespaceConfig is the configuration for a namespace

type RedisConfig

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

RedisConfig describes a connection to a Redis cache.

func RedisConfigFromMap

func RedisConfigFromMap(orig map[string]string) *RedisConfig

RedisConfigFromMap returns a Redis config from a map

func (*RedisConfig) Validate

func (r *RedisConfig) Validate() error

type Schedule

type Schedule struct {
	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 schedule settings for a workflow

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.

type Trigger

type Trigger struct {
	Source    string `yaml:"source,omitempty" json:"source,omitempty"`
	Topic     string `yaml:"topic" json:"topic"`
	Sink      string `yaml:"sink" json:"sink"`
	SinkTopic string `yaml:"sinkTopic" json:"sinkTopic"`
}

Trigger represents a trigger for a workflow.

type WasmModuleRef

type WasmModuleRef struct {
	Name string `json:"name"`
	FQMN string `json:"fqmn"`
	Data []byte `json:"data"`
}

WasmModuleRef is a reference to a Wasm module This is a duplicate of sat/engine/moduleref/WasmModuleRef (for JSON serialization purposes)

func NewWasmModuleRef

func NewWasmModuleRef(name, fqmn string, data []byte) *WasmModuleRef

type Workflow

type Workflow struct {
	Name     string                  `yaml:"name" json:"name"`
	Steps    []executable.Executable `yaml:"steps" json:"steps"`
	Response string                  `yaml:"response,omitempty" json:"response,omitempty"`
	Schedule *Schedule               `yaml:"schedule,omitempty" json:"schedule,omitempty"`
	Triggers []Trigger               `yaml:"triggers" json:"triggers"`
}

Workflow represents the mapping between an input and a composition of functions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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