Documentation ¶
Overview ¶
Package modconfig provides matchers for config.Map that query modules registry and parse inline module definitions.
They should be used instead of manual querying when there is need to reference a module instance in the configuration.
See ModuleFromNode documentation for explanation of what is 'args' for some functions (DeliveryTarget).
Index ¶
- func DeliveryDirective(m *config.Map, node config.Node) (interface{}, error)
- func DeliveryTarget(globals map[string]interface{}, args []string, block config.Node) (module.DeliveryTarget, error)
- func FailActionDirective(_ *config.Map, node config.Node) (interface{}, error)
- func GroupFromNode(defaultModule string, args []string, inlineCfg config.Node, ...) error
- func IMAPFilter(globals map[string]interface{}, args []string, block config.Node) (module.IMAPFilter, error)
- func MessageCheck(globals map[string]interface{}, args []string, block config.Node) (module.Check, error)
- func ModuleFromNode(preferredNamespace string, args []string, inlineCfg config.Node, ...) error
- func MsgModifier(globals map[string]interface{}, args []string, block config.Node) (module.Modifier, error)
- func ParseRejectDirective(args []string) (*exterrors.SMTPError, error)
- func StorageDirective(m *config.Map, node config.Node) (interface{}, error)
- func TableDirective(m *config.Map, node config.Node) (interface{}, error)
- type FailAction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeliveryDirective ¶
deliveryDirective is a callback for use in config.Map.Custom.
It does all work necessary to create a module instance from the config directive with the following structure:
directive_name mod_name [inst_name] [{ inline_mod_config }]
Note that if used configuration structure lacks directive_name before mod_name - this function should not be used (call DeliveryTarget directly).
func DeliveryTarget ¶
func FailActionDirective ¶
func GroupFromNode ¶
func GroupFromNode(defaultModule string, args []string, inlineCfg config.Node, globals map[string]interface{}, moduleIface interface{}) error
GroupFromNode provides a special kind of ModuleFromNode syntax that allows to omit the module name when defining inine configuration. If it is not present, name in defaultModule is used.
func IMAPFilter ¶
func MessageCheck ¶
func ModuleFromNode ¶
func ModuleFromNode(preferredNamespace string, args []string, inlineCfg config.Node, globals map[string]interface{}, moduleIface interface{}) error
ModuleFromNode does all work to create or get existing module object with a certain type. It is not used by top-level module definitions, only for references from other modules configuration blocks.
inlineCfg should contain configuration directives for inline declarations. args should contain values that are used to create module. It should be either module name + instance name or just module name. Further extensions may add other string arguments (currently, they can be accessed by module instances as inlineArgs argument to constructor).
It checks using reflection whether it is possible to store a module object into modObj pointer (e.g. it implements all necessary interfaces) and stores it if everything is fine. If module object doesn't implement necessary module interfaces - error is returned. If modObj is not a pointer, ModuleFromNode panics.
preferredNamespace is used as an implicit prefix for module name lookups. Module with name preferredNamespace + "." + args[0] will be preferred over just args[0]. It can be omitted.
func MsgModifier ¶
Types ¶
type FailAction ¶
FailAction specifies actions that messages pipeline should take based on the result of the check.
Its check module responsibility to apply FailAction on the CheckResult it returns. It is intended to be used as follows:
Add the configuration directive to allow user to specify the action:
cfg.Custom("SOME_action", false, false, func() (interface{}, error) { return modconfig.FailAction{Quarantine: true}, nil }, modconfig.FailActionDirective, &yourModule.SOMEAction)
return in func literal is the default value, you might want to adjust it.
Call yourModule.SOMEAction.Apply on CheckResult containing only the Reason field:
func (yourModule YourModule) CheckConnection() module.CheckResult { return yourModule.SOMEAction.Apply(module.CheckResult{ Reason: ..., }) }
func ParseActionDirective ¶
func ParseActionDirective(args []string) (FailAction, error)
func (FailAction) Apply ¶
func (cfa FailAction) Apply(originalRes module.CheckResult) module.CheckResult
Apply merges the result of check execution with action configuration specified in the check configuration.