route

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ROUTE_ID_REGEX = `^[a-zA-Z0-9][a-zA-Z0-9_\-\.]*[a-zA-Z0-9]$`
View Source
const ROUTE_STATUS_RUNNING = "running"
View Source
const ROUTE_STATUS_STOPPED = "stopped"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Id           string         `json:"id,omitempty"`           // route ID
	TenantId     tenant.Id      `json:"tenant,omitempty"`       // TenantId. Derived from URL path. Should not be marshaled
	UserId       string         `json:"userId,omitempty"`       // user ID / author of route
	Region       string         `json:"region,omitempty"`       // optional region of route for active-active scenarios - if present, route will only be active in a single region
	Inactive     bool           `json:"inactive"`               // if true, route will not execute
	Status       string         `json:"status,omitempty"`       // a route running on this instance will have status running, otherwise status will be stopped
	RouteType    string         `json:"routeType,omitempty"`    // route type can be trigger, action, trigger-action or blank
	Name         string         `json:"name,omitempty"`         // optional unique name for route
	Desc         string         `json:"desc,omitempty"`         // optional description for route
	Origin       string         `json:"origin,omitempty"`       // optional reference to route owner, e.g. Flow ID in case of Gears
	Receiver     PluginConfig   `json:"receiver,omitempty"`     // source plugin configuration
	Sender       PluginConfig   `json:"sender,omitempty"`       // destination plugin configuration
	FilterChain  []PluginConfig `json:"filterChain,omitempty"`  // filter chain configuration
	DeliveryMode string         `json:"deliveryMode,omitempty"` // possible values: fire_and_forget, at_least_once, exactly_once
	Debug        bool           `json:"debug,omitempty"`        // if true generate debug logs and metrics for events taking this route
	Created      int64          `json:"created,omitempty"`      // time on when route was created, in unix timestamp seconds
	Modified     int64          `json:"modified,omitempty"`     // last time when route was modified, in unix timestamp seconds
}

func (*Config) Hash

func (pc *Config) Hash(ctx context.Context) string

Hash returns the md5 hash of a route config

func (*Config) Validate

func (rc *Config) Validate(ctx context.Context) error

Validate returns an error if the route config is invalid and nil otherwise

type InvalidRouteError

type InvalidRouteError struct {
	Err error
}

func (*InvalidRouteError) Error

func (e *InvalidRouteError) Error() string

func (*InvalidRouteError) Unwrap

func (e *InvalidRouteError) Unwrap() error

type PluginConfig

type PluginConfig struct {
	Plugin       string      `json:"plugin,omitempty"`       // plugin or filter type, e.g. kafka, kds, sqs, webhook, filter
	Name         string      `json:"name,omitempty"`         // plugin label to allow multiple instances of otherwise identical plugin configurations
	Config       interface{} `json:"config,omitempty"`       // plugin specific configuration parameters
	FragmentName string      `json:"fragmentName,omitempty"` // plugin reference id to load config as a fragment (optional)
}

func (*PluginConfig) Hash

func (pc *PluginConfig) Hash(ctx context.Context) string

Hash returns the md5 hash of the plugin config

func (*PluginConfig) Validate

func (pc *PluginConfig) Validate(ctx context.Context) error

Validate returns an error if the plugin config is invalid and nil otherwise

type Route

type Route struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Route) Run

func (*Route) Stop

func (rte *Route) Stop(ctx context.Context) error

type RouteNotFoundError

type RouteNotFoundError struct {
	TenantId tenant.Id
	RouteId  string
}

func (*RouteNotFoundError) Error

func (e *RouteNotFoundError) Error() string

type RouteStorer

type RouteStorer interface {
	//Get all routes of all tenants
	GetAllRoutes(context.Context) ([]Config, error)

	//If route is not found, the function should return a item not found error
	GetRoute(context.Context, tenant.Id, string) (Config, error)

	GetAllTenantRoutes(ctx context.Context, id tenant.Id) ([]Config, error)

	//SetRoute will add the route if it new or update the route if
	//it is an existing one. It will also update the create time and
	//modified time of the route where appropriate.
	SetRoute(context.Context, Config) error

	SetRoutes(context.Context, []Config) error

	DeleteRoute(context.Context, tenant.Id, string) error

	DeleteRoutes(context.Context, tenant.Id, []string) error
}

All route operations are synchronous. The storer should respect the cancellation from the context and cancel its operation gracefully when desired.

type Router

type Router interface {
	Run(r receiver.Receiver, f filter.Filterer, s sender.Sender) error
	Stop(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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