Documentation ¶
Index ¶
- Constants
- func BuiltinActions() map[string]*sdkAct.Action
- func BuiltinPolicies() map[string]*sdkAct.Policy
- func BuiltinSignals() map[string]*sdkAct.Signal
- func Log(data map[string]any, params ...sdkAct.Parameter) (any, error)
- func Passthrough(map[string]any, ...sdkAct.Parameter) (any, error)
- func Terminate(_ map[string]any, params ...sdkAct.Parameter) (any, error)
- func WithLogger(logger zerolog.Logger) sdkAct.Parameter
- func WithResult(result map[string]any) sdkAct.Parameter
- type IRegistry
- type Registry
Constants ¶
const ( // TerminateDefaultParamCount is the default parameter count for the terminate action. TerminateDefaultParamCount = 2 // LogDefaultKeyCount is the default key count in the metadata for the log action. LogDefaultKeyCount = 3 // These are the keys used to pass the logger and the result to the built-in actions. LoggerKey = "__logger__" ResultKey = "__result__" )
Variables ¶
This section is empty.
Functions ¶
func BuiltinActions ¶
BuiltinActions returns a map of built-in actions.
func BuiltinPolicies ¶
BuiltinPolicies returns a map of built-in policies.
func BuiltinSignals ¶
BuiltinSignals returns a map of built-in signals.
func Passthrough ¶
Passthrough is a built-in action that always returns true and no error.
func Terminate ¶
Terminate is a built-in action that terminates the connection if the terminate signal is true and the policy is set to "stop". The action can optionally receive a result parameter.
func WithLogger ¶
WithLogger returns a parameter with the logger to be used by the action. This is automatically prepended to the parameters when running an action.
Types ¶
type Registry ¶
type Registry struct { Logger zerolog.Logger // Timeout for policy evaluation. PolicyTimeout time.Duration // Default timeout for running actions DefaultActionTimeout time.Duration Signals map[string]*sdkAct.Signal Policies map[string]*sdkAct.Policy Actions map[string]*sdkAct.Action DefaultPolicyName string DefaultPolicy *sdkAct.Policy DefaultSignal *sdkAct.Signal }
Registry keeps track of all policies and actions.
func NewActRegistry ¶
NewActRegistry creates a new act registry with the specified default policy and timeout and the builtin signals, policies, and actions.
func (*Registry) Run ¶
func (r *Registry) Run( output *sdkAct.Output, params ...sdkAct.Parameter, ) (any, *gerr.GatewayDError)
Run runs the function associated with the output.MatchedPolicy and returns its result. If the action is synchronous, the result is returned immediately. If the action is asynchronous, the result is nil and the error is ErrAsyncAction, which is a sentinel error to indicate that the action is running asynchronously.