trigger

package
Version: v0.5.8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: BSD-3-Clause Imports: 10 Imported by: 116

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factories

func Factories() map[string]Factory

func NewContext

func NewContext(parentCtx context.Context, attrs []*data.Attribute) context.Context

NewContext returns a new Context that carries the trigger data. DEPRECATED

func NewContextWithData

func NewContextWithData(parentCtx context.Context, contextData *ContextData) context.Context

NewContext returns a new Context that carries the trigger data. DEPRECATED

func NewHandlerContext added in v0.5.6

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

NewHandlerContext add the handler info to a new child context

func NewInitialContext

func NewInitialContext(attrs []*data.Attribute, config *HandlerConfig) context.Context

DEPRECATED

func RegisterFactory

func RegisterFactory(ref string, f Factory) error

Types

type ActionConfig added in v0.5.6

type ActionConfig struct {
	*action.Config

	Mappings *data.IOMappings `json:"mappings"`

	Act action.Action
}

ActionConfig is the configuration for the Action

type Config

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

	// Deprecated: Use Output
	Outputs map[string]interface{} `json:"outputs"`
}

Config is the configuration for a Trigger

func (*Config) FixUp

func (c *Config) FixUp(metadata *Metadata)

func (*Config) GetSetting

func (c *Config) GetSetting(setting string) string

type ContextData

type ContextData struct {
	Attrs      []*data.Attribute
	HandlerCfg *HandlerConfig
}

func ExtractContextData

func ExtractContextData(ctx context.Context) (*ContextData, bool)

DEPRECATED

type Factory

type Factory interface {
	New(config *Config) Trigger
}

Factory is used to create new instances for a trigger

func GetFactory

func GetFactory(ref string) Factory

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(config *HandlerConfig, act action.Action, outputMd map[string]*data.Attribute, replyMd map[string]*data.Attribute, runner action.Runner) *Handler

func NewHandlerAlt added in v0.5.7

func NewHandlerAlt(internal HandlerInf) *Handler

func (*Handler) GetOutput

func (h *Handler) GetOutput() map[string]interface{}

func (*Handler) GetSetting

func (h *Handler) GetSetting(setting string) (interface{}, bool)

func (*Handler) GetStringSetting

func (h *Handler) GetStringSetting(setting string) string

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, triggerData map[string]interface{}) (map[string]*data.Attribute, error)

func (*Handler) String

func (h *Handler) String() string

type HandlerConfig

type HandlerConfig struct {
	Name     string                 `json:"name,omitempty"`
	Settings map[string]interface{} `json:"settings"`
	Output   map[string]interface{} `json:"output"`
	Action   *ActionConfig

	// Deprecated: Use Action (*action.Config)
	ActionId string `json:"actionId"`
	// Deprecated: Use Action (*action.Config)
	ActionMappings *data.IOMappings `json:"actionMappings,omitempty"`
	// Deprecated: Use Action (*action.Config)
	ActionOutputMappings []*data.MappingDef `json:"actionOutputMappings,omitempty"`
	// Deprecated: Use Action (*action.Config)
	ActionInputMappings []*data.MappingDef `json:"actionInputMappings,omitempty"`
	// Deprecated: Use Output
	Outputs map[string]interface{} `json:"outputs"`
	// contains filtered or unexported fields
}

func (*HandlerConfig) GetSetting

func (hc *HandlerConfig) GetSetting(setting string) string

type HandlerInf added in v0.5.7

type HandlerInf interface {
	Handle(ctx context.Context, triggerData map[string]interface{}) (map[string]*data.Attribute, error)

	GetSetting(setting string) (interface{}, bool)

	GetOutput() map[string]interface{}

	GetStringSetting(setting string) string

	String() string
}

type HandlerInfo added in v0.5.6

type HandlerInfo struct {
	Name string
}

func HandlerFromContext added in v0.5.6

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

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

type HandlerMetadata

type HandlerMetadata struct {
	Settings []*data.Attribute `json:"settings"`
}

EndpointMetadata is the metadata for a Trigger Endpoint

type InitContext

type InitContext interface {

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

InitContext is the initialization context for the trigger instance

type InitOld deprecated

type InitOld interface {

	// Deprecated: Triggers should implement trigger.Initializable interface
	Init(actionRunner action.Runner)
}

Deprecated: No longer used

type Initializable

type Initializable interface {

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

Initializable interface should be implemented by all Triggers, the Initialize method will eventually move up to Trigger to replace the the old "Init" method

type LegacyRunner deprecated

type LegacyRunner struct {
	// contains filtered or unexported fields
}

Deprecated: Temporarily generated for backwards compatibility support

func NewLegacyRunner

func NewLegacyRunner(runner action.Runner, metadata *Metadata) *LegacyRunner

func (*LegacyRunner) Execute

func (*LegacyRunner) Execute(ctx context.Context, act action.Action, inputs map[string]*data.Attribute) (results map[string]*data.Attribute, err error)

func (*LegacyRunner) RegisterHandler

func (lr *LegacyRunner) RegisterHandler(h *Handler)

func (*LegacyRunner) Run

func (lr *LegacyRunner) Run(ctx context.Context, act action.Action, uri string, options interface{}) (code int, data interface{}, err error)

func (*LegacyRunner) RunAction

func (lr *LegacyRunner) RunAction(ctx context.Context, act action.Action, options map[string]interface{}) (results map[string]*data.Attribute, err error)

type Metadata

type Metadata struct {
	ID       string
	Version  string
	Handler  *HandlerMetadata
	Settings map[string]*data.Attribute
	Output   map[string]*data.Attribute
	Reply    map[string]*data.Attribute
}

Metadata is the metadata for a Trigger

func NewMetadata

func NewMetadata(jsonMetadata string) *Metadata

NewMetadata creates a Metadata object from the json representation todo should return error instead of panic

func (*Metadata) OutputsToAttrs

func (md *Metadata) OutputsToAttrs(outputData map[string]interface{}, coerce bool) ([]*data.Attribute, error)

OutputsToAttrs converts the supplied output data to attributes todo remove coerce option, coercion now happens by default

func (*Metadata) UnmarshalJSON

func (md *Metadata) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the default UnmarshalJSON for Metadata

type Trigger

type Trigger interface {
	managed.Managed

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

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

Jump to

Keyboard shortcuts

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