-
Notifications
You must be signed in to change notification settings - Fork 13
Plugins
This page describes plugins, including their configuration parameters, expected input payload, output payload, and actions.
The following pertain to all plugins.
These features are defined in the Node
superclass in the module snewpdag.dag
.
field | type | description |
---|---|---|
name |
string | unique name of the plugin instance |
class |
string | name identifying the plugin class |
observe |
list(strings) | list of plugins to observe, identified by name |
kwargs |
dict | a dictionary of arguments and values |
field | type | description |
---|---|---|
action |
string | the action verb, indicating which action the plugin is to take |
history |
History object |
names of plugins which have handled this payload |
field | type | description |
---|---|---|
action |
string | the action verb, indicating which action the downstream plugin is to take |
history |
History object |
history of payload, with current plugin name appended |
By default, alert
, revoke
, reset
, and report
actions are simply passed along, while other
prints out an error message and is not passed along. Override these methods to change the behavior. It isn't necessary to override every action method; if the default behavior is what you want, don't override it.
It's sometimes useful to find out which source (i.e., a plugin being observed) is the origin of the current action, and to assign each source a unique integer identifier. For this purpose, Node
includes the utility methods watch_index()
and `last_watch_index().
watch_index(source)
returns the index of the node with the name in source
. It the node is observing N other nodes, the return value will lie between 0 and N-1, inclusive.
last_watch_index()
calls watch_index()
with the node last named in the payload's history. This method only works if you use the usual action methods, rather than overriding update()
. If you override update()
, you will need to call watch_index()
.
self.last_source
also contains the name of the source node.