Documentation ¶
Overview ¶
Package actions provides types and interfaces necessary to write action modules.
Index ¶
- func GetActionModulesList() (moduleslist []string)
- func GetAllActions() map[string][]ActionDesc
- func RegisterActionModule(name string, ac ActionModuleInterface)
- func RunAction(module string, action string, data map[string]interface{}) (map[string]interface{}, error)
- func SetupActionModules(cfp configprovider.ConfigProviderInterface, actionslist []string)
- type ActionDesc
- type ActionModuleInterface
- type ArgType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetActionModulesList ¶
func GetActionModulesList() (moduleslist []string)
GetActionModulesList returns the list of all action modules.
func GetAllActions ¶
func GetAllActions() map[string][]ActionDesc
func RegisterActionModule ¶
func RegisterActionModule(name string, ac ActionModuleInterface)
RegisterActionModule registers the action module. Must be called from the init() of modules.
func RunAction ¶
func RunAction(module string, action string, data map[string]interface{}) (map[string]interface{}, error)
RunAction calls the ActionHandler() of the module containing the action.
func SetupActionModules ¶
func SetupActionModules(cfp configprovider.ConfigProviderInterface, actionslist []string)
SetupActionModules gets the configuration and calls the Setup() function of the modules specified by actionslist.
Types ¶
type ActionDesc ¶
type ActionDesc struct { In []ArgType `json:"data_in"` Out []ArgType `json:"data_out"` Name string `json:"name"` }
Type describing an action
type ActionModuleInterface ¶
type ActionModuleInterface interface { Setup(config []byte) error Actions() (map[string][]ArgType, map[string][]ArgType) ActionHandler() func(string, map[string]interface{}) (map[string]interface{}, error) }
ActionModuleInterface is the interface actions modules must implement. Setup() is called once when CSF starts and is used to configure and or init modules. Actions() returns a map of in and out parameters where Keys are actions names and values are lists of parameters of the given action. ActionHandler() is called everytime an action of the module needs to be Executed. It is basically a switch that call the right function.