apama.eplplugin module

Contains classes used to define EPL plug-ins in Python.

EPL plug-ins must inherit from EPLPluginBase and have methods on them decorated with the EPLAction decorator to declare the EPL type of the methods.

There are also several classes defined to pass custom EPL types from EPL to Python.

class apama.eplplugin.Any

Bases: tuple

Any class representing the any variant type in EPL.

type

String name of the EPL type contained in the any, may be None if empty. Uses EPL-format type names, for example: dictionary<string, sequence<integer> >

value

Contents of the any. Will be of the equivalent Python type to the EPL type named in type, or None if empty.

class apama.eplplugin.Channel

Bases: tuple

Channel class represents an Apama channel.

channel

A string representing the name for the channel.

context

A context object for the channel.

class apama.eplplugin.Context(name, contextId)[source]

Bases: object

Context class represents an Apama context.

__init__(name, contextId)[source]

Initialise the context

Parameters:
  • name – The string name of the context.
  • contextId – The integer id of the context.
getName()[source]

Retrieve the name of this context.

Returns:The string name of the context.
repr()[source]

Stringify this context.

Returns:A string representation of the contexts, containing the context name and ID.
str()[source]

Stringify the context.

Returns:A string representation of the context, containing the context name.
class apama.eplplugin.Correlator[source]

Bases: object

Contains static methods to interact with the correlator directly, such as sending events.

static getCurrentContext()[source]

Get the current context we are running in.

Returns:A Context object representing the current execution context, or None if called on a background thread.
static sendTo(destination, event, type=None)[source]

Send an event from python to a destination within the correlator.

sendTo takes two or three arguments, but can only be invoked with positional arguments, not named arguments. For example:

  • Correlator.sendTo(“channelname”, “MyEvent(123, 456)”)
  • Correlator.sendTo(Channel(“channelname”), {“i”:123, “j”:456}, type=”MyEvent”)
  • Correlator.sentTo(Correlator.getCurrentContext(), Event(“MyEvent”, {“i”:123, “j”:456}))
Parameters:
  • destination – Either a string representing a channel name, a Context object or a Channel object containing either a string channel name or a Context object. The event will be sent to the specified context, or any context subscribed to the specified channel. (required)
  • event – Either a string in Apama event string format; a dictionary of string field names to values (in which case type must be specified); an Event object. (required)
  • type – The fully-qualified name of an EPL event type. (optional)

This method may block if sending to a context with a full queue. You may not call this method from the plugin module (static) code or from the plugin constructor.

apama.eplplugin.EPLAction(actionsig, actionname=None)[source]

EPLAction is the available decorator that can be set on a method to allow access to the method from EPL. For example @EPLAction(“action<> returns string”, actionname=”eplaction”)

Parameters:
  • actionsig – The EPL action signature used to access the decorated method. Uses the same syntax as declaring action variables, for example: action<integer> returns string.
  • actionname – The action name to use in EPL to access the decorated method. Optional, defaults to the name of the method in Python.
class apama.eplplugin.EPLPluginBase(init)[source]

Bases: object

EPLPluginBase class which all Python EPL plug-in instances should be inherited from, and therefore defines all the ways in which the plug-in can interact with the correlator.

Methods on a Python EPL plug-in must be decorated with the EPLPlugin decorator in order to be exposed to EPL.

__init__(init)[source]

Initialize the plug-in.

Parameters:init – An opaque structure which must be passed up from the plug-in constructor verbatim.
getConfig()[source]

Get the plug-in instance configuration.

Returns:A dictionary with string keys as specified in the configuration file for this plug-in instance.
getLogger()[source]

Get a reference to the system logger.

Returns:A logger object which can be used to log to the system log file.
class apama.eplplugin.Event

Bases: tuple

Event is a class containing type and fields.

fields

A dictionary containing key-value pairs of field name and value.

type

A string containing the fully-qualified name of this Event instance. For example: apama.tests.myEvent

class apama.eplplugin.Location

Bases: tuple

Location class defines a position in Apama using 2 coordinates.

x1

Float defining the x position of the first coordinate pair.

x2

Float defining the x position of the second coordinate pair.

y1

Float defining the y position of the first coordinate pair.

y2

Float defining the y position of the second coordinate pair.