Apama EPL Plug-ins¶
Contains classes used to define EPL plug-ins written in Python that run inside the Apama correlator.
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.
Event¶
- class apama.eplplugin.Event(type, fields)¶
Bases:
tuple
Event is a class containing type and fields.
Create new instance of Event(type, fields)
- _asdict()¶
Return a new dict which maps field names to their values.
- classmethod _make(iterable)¶
Make a new Event object from a sequence or iterable
- _replace(**kwds)¶
Return a new Event object replacing specified fields with new values
- 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
Location¶
- class apama.eplplugin.Location(x1, y1, x2, y2)¶
Bases:
tuple
Location class defines a position in Apama using 2 coordinates.
Create new instance of Location(x1, y1, x2, y2)
- _asdict()¶
Return a new dict which maps field names to their values.
- classmethod _make(iterable)¶
Make a new Location object from a sequence or iterable
- _replace(**kwds)¶
Return a new Location object replacing specified fields with new values
- 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.
Context¶
- class apama.eplplugin.Context(name, contextId)[source]¶
Bases:
object
Context class represents an Apama EPL context.
- Parameters
name – The string name of the context.
contextId – The integer id of the context.
- str()[source]¶
Stringify the context.
- Returns
A string representation of the context, containing the context name.
Channel¶
- class apama.eplplugin.Channel(channel, context)¶
Bases:
tuple
Channel class represents an Apama channel.
Create new instance of Channel(channel, context)
- _asdict()¶
Return a new dict which maps field names to their values.
- classmethod _make(iterable)¶
Make a new Channel object from a sequence or iterable
- _replace(**kwds)¶
Return a new Channel object replacing specified fields with new values
- channel¶
A string representing the name for the channel.
- context¶
A context object for the channel.
Any¶
- class apama.eplplugin.Any(type, value)¶
Bases:
tuple
Any class representing the any variant type in EPL.
Create new instance of Any(type, value)
- _asdict()¶
Return a new dict which maps field names to their values.
- classmethod _make(iterable)¶
Make a new Any object from a sequence or iterable
- _replace(**kwds)¶
Return a new Any object replacing specified fields with new values
- 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.
Correlator¶
- class apama.eplplugin.Correlator[source]¶
Bases:
object
Contains static methods to interact with the correlator directly from an EPL plug-in, such as by sending events.
- 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}))
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.
- 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 (str) – The fully-qualified name of an EPL event type. (optional)
EPLPluginBase¶
- class apama.eplplugin.EPLPluginBase(init)[source]¶
Bases:
object
This is the base class which all Python EPL plug-in instances should inherit from, and therefore defines all the ways in which the plug-in can interact with the correlator.
Methods on a Python EPL plug-in class must be decorated with the
EPLAction
decorator in order to be exposed to EPL.- Parameters
init – An opaque structure which must be passed up from the plug-in constructor verbatim.
EPLAction¶
- 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 (str) – 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 (str) – The action name to use in EPL to access the decorated method. Optional, defaults to the name of the method in Python.