Version: v1.6.5 Latest Latest

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

Go to latest
Published: Mar 3, 2023 License: BSD-3-Clause Imports: 21 Imported by: 85




View Source
const (
	INITIALIZING     = "Initializing"
	INITIALIZED      = "Initialized"
	INIT_FAILED      = "InitFailed"
	STARTED          = "Started"
	STOPPED          = "Stopped"
	FAILED           = "Failed"
	COMPLETED        = "Completed"
	TriggerEventType = "triggerevent"


This section is empty.


func AppendEventDataToContext added in v1.0.0

func AppendEventDataToContext(parentCtx context.Context, data map[string]string) context.Context

NewContextWithEventData add event data to a new child context. This event data will be associated handler events.

func ExtractEventDataFromContext added in v1.0.0

func ExtractEventDataFromContext(ctx context.Context) (map[string]string, bool)

ExtractEventDataFromContext returns the event data stored in the context, if any.

func Factories

func Factories() map[string]Factory

func GetHandleStartTimeFromContext added in v1.4.0

func GetHandleStartTimeFromContext(ctx context.Context) time.Time

func GetHandlerEventIdFromContext added in v1.4.0

func GetHandlerEventIdFromContext(ctx context.Context) string

func GetLogger

func GetLogger(ref string) log.Logger

func LegacyRegister

func LegacyRegister(ref string, f Factory) error


func NewContextWithEventId added in v1.4.0

func NewContextWithEventId(parentCtx context.Context, eventId string) context.Context

NewContextWithEventId new context by adding event id to the context

func NewHandlerContext

func NewHandlerContext(parentCtx context.Context, config *HandlerConfig) context.Context

NewHandlerContext add the handler info to a new child context

func PostHandlerEvent added in v0.10.2

func PostHandlerEvent(hStatus Status, hName, tName string, data map[string]string)

Publish handler event

func PostTriggerEvent added in v0.10.2

func PostTriggerEvent(tStatus Status, name string)

func Register

func Register(trigger Trigger, f Factory) error


type ActionConfig

type ActionConfig struct {
	If     string                 `json:"if,omitempty"`
	Input  map[string]interface{} `json:"input,omitempty"`
	Output map[string]interface{} `json:"output,omitempty"`

	Act action.Action `json:"-,omitempty"`

ActionConfig is the configuration for the Action

type Config

type Config struct {
	Id       string                 `json:"id"`
	Ref      string                 `json:"ref"`
	Settings map[string]interface{} `json:"settings"`
	Handlers []*HandlerConfig       `json:"handlers"`

	Type string `json:"type,omitempty"`

Config is the configuration for a Trigger

func (*Config) FixUp

func (c *Config) FixUp(md *Metadata, resolver resolve.CompositeResolver) error

type Descriptor

type Descriptor struct {
	ID      string `json:"ref"`
	Version string `json:"version"`

type EventFlowControlAware added in v1.6.0

type EventFlowControlAware interface {
	// Resume suspended trigger
	Resume() error

	// Pause trigger
	Pause() error

EventFlowControlAware trigger can be paused or resumed by the engine

type Factory

type Factory interface {

	// Metadata returns the metadata of the trigger
	Metadata() *Metadata

	// New create a new Trigger
	New(config *Config) (Trigger, error)

Factory is used to create new instances of a trigger

func GetFactory

func GetFactory(ref string) Factory

type Handler

type Handler interface {
	Name() string
	Logger() log.Logger
	Settings() map[string]interface{}
	Schemas() *SchemaConfig
	Handle(ctx context.Context, triggerData interface{}) (map[string]interface{}, error)

func NewHandler

func NewHandler(config *HandlerConfig, acts []action.Action, mf mapper.Factory, ef expression.Factory, runner action.Runner, logger log.Logger) (Handler, error)

type HandlerConfig

type HandlerConfig struct {
	Name     string                 `json:"name,omitempty"`
	Settings map[string]interface{} `json:"settings"`
	Actions  []*ActionConfig        `json:"actions"`
	Schemas  *SchemaConfig          `json:"schemas,omitempty"`
	// contains filtered or unexported fields

func (*HandlerConfig) UnmarshalJSON

func (hc *HandlerConfig) UnmarshalJSON(d []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for TaskInst

type HandlerEvent added in v0.10.2

type HandlerEvent interface {
	// Name of trigger this handler belongs to
	TriggerName() string
	// Name of the handler
	HandlerName() string
	// Status of handler. Valid status - INITIALIZED, STARTED, COMPLETED, FAILED
	Status() Status
	// Handler specific tags set by the underlying implementation e.g. method and path by REST trigger handler or
	// topic name by Kafka trigger handler. This is useful when peek view of trigger(and handlers) is desired.
	Tags() map[string]string

type HandlerEventConfig added in v1.0.0

type HandlerEventConfig interface {
	// SetDefaultEventData sets the default event data to use for a handler
	SetDefaultEventData(data map[string]string)

HandlerEventConfig is an interface that can be used to set the default event data that is used in handler events

type HandlerInfo

type HandlerInfo struct {
	Name      string
	EventId   string
	StartTime time.Time

func HandlerFromContext

func HandlerFromContext(ctx context.Context) (*HandlerInfo, bool)

HandlerFromContext returns the handler info stored in the context, if any.

type InitContext

type InitContext interface {

	// Logger the logger for the trigger
	Logger() log.Logger

	// GetHandlers gets the handlers associated with the trigger
	GetHandlers() []Handler

InitContext is the initialization context for the trigger instance

type Metadata

type Metadata struct {
	Settings        map[string]data.TypedValue
	HandlerSettings map[string]data.TypedValue
	Output          map[string]data.TypedValue
	Reply           map[string]data.TypedValue

	ID string

func NewMetadata

func NewMetadata(mdStructs ...interface{}) *Metadata

type ReconfigurableTrigger added in v1.6.4

type ReconfigurableTrigger interface {
	// Reconfigure is called to reconfigure trigger implementation
	Reconfigure(config *Config, handlers []Handler) error

ReconfigurableTrigger is object that supports dynamic reconfiguration of trigger

type SchemaConfig

type SchemaConfig struct {
	Output map[string]interface{} `json:"output,omitempty"`
	Reply  map[string]interface{} `json:"reply,omitempty"`

type Status added in v0.10.2

type Status string

func (Status) String added in v0.10.2

func (s Status) String() string

type Trigger

type Trigger interface {

	// Initialize is called to initialize the Trigger
	Initialize(ctx InitContext) error

Trigger is object that triggers/starts flow instances and is managed by an engine

type TriggerEvent added in v0.10.2

type TriggerEvent interface {
	// Name of trigger
	Name() string
	Status() Status

Trigger Event

Jump to

Keyboard shortcuts

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