actions

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package actions provides action implementations and factory for creating actions from configuration.

Package actions provides action implementations and a factory for creating actions from configuration. It supports REST and gRPC actions, as well as plugin-based custom actions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(ac GenericAction, input interface{}) error

Execute runs the provided action with the given input. This is a convenience function that calls action.Handler() and executes the result.

Types

type GenericAction

type GenericAction interface {
	// Name returns the action's display name.
	Name() string
	// Description returns a human-readable description of what the action does.
	Description() string
	// Type returns the type identifier for this action (e.g., "rest", "grpc").
	Type() string
	// Init initializes the action with the provided configuration map.
	Init(config map[string]interface{}) error
	// Handler returns a function that executes the action with the given input.
	// The function returns an error if the action fails.
	Handler() func(interface{}) error
}

GenericAction defines the interface that all action implementations must satisfy. Actions are used to handle events when triggers match.

func Factory

func Factory(cfg config.ActionConfig) (GenericAction, error)

Factory creates an action instance from an ActionConfig.

func New

func New(path string) (GenericAction, error)

New loads a custom action from a Go plugin (.so) file. The plugin must export a symbol named "Plugin" that implements GenericAction. Returns an error if the plugin cannot be opened or does not implement GenericAction.

func NewGrpcActionFromConfig

func NewGrpcActionFromConfig(configMap map[string]interface{}) (GenericAction, error)

NewGrpcActionFromConfig creates a new gRPC action from configuration map.

func NewRestActionFromConfig

func NewRestActionFromConfig(configMap map[string]interface{}) (GenericAction, error)

NewRestActionFromConfig creates a new REST action from configuration map.

type RestAction

type RestAction interface {
	Name() string
	Description() string
	Type() string
	Init(config map[string]interface{}) error
	Handler() func(input RestInput) error
}

RestAction defines the interface for REST actions.

type RestInput

type RestInput struct {
	Req *http.Request
	Res *http.Response
}

RestInput represents the input for a REST action.

Jump to

Keyboard shortcuts

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