Skip to content

Plugins

J Tseng edited this page Jun 6, 2021 · 6 revisions

This page describes plugins, including their configuration parameters, expected input payload, output payload, and actions.

General

The following pertain to all plugins.

These features are defined in the Node superclass in the module snewpdag.dag.

Configuration

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

Input

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

Output

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

Actions

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.

Other methods

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.

Clone this wiki locally