Skip to content

Streampipes function

StreamPipesFunction(function_definition=None)

Bases: ABC

Abstract implementation of a StreamPipesFunction.

A StreamPipesFunction allows users to get the data of a StreamPipes data streams easily. It makes it possible to work with the live data in python and enables to use the powerful data analytics libraries there.

PARAMETER DESCRIPTION
function_definition

the definition of the function that contains metadata about the connected function

TYPE: Optional[FunctionDefinition] DEFAULT: None

ATTRIBUTE DESCRIPTION
output_collectors

List of all output collectors which are created based on the provided function definitions.

TYPE: Dict[str, OutputCollector]

add_output(stream_id, event)

Send an event via an output data stream to StreamPipes

PARAMETER DESCRIPTION
stream_id

The id of the output data stream

TYPE: str

event

The event which should be sent

TYPE: Dict[str, Any]

RETURNS DESCRIPTION
None

getFunctionId()

Returns the id of the function.

RETURNS DESCRIPTION
function_id

Identification object of the StreamPipes function

TYPE: FunctionId

onEvent(event, streamId) abstractmethod

Is called for every event of a data stream.

PARAMETER DESCRIPTION
event

The received event from the data stream.

TYPE: Dict[str, Any]

streamId

The id of the data stream which the event belongs to.

TYPE: str

RETURNS DESCRIPTION
None

onServiceStarted(context) abstractmethod

Is called when the function gets started.

PARAMETER DESCRIPTION
context

The context in which the function gets started.

TYPE: FunctionContext

RETURNS DESCRIPTION
None

onServiceStopped() abstractmethod

Is called when the function gets stopped.

RETURNS DESCRIPTION
None

requiredStreamIds()

Get the ids of the streams needed by the function.

RETURNS DESCRIPTION
stream_ids

List of the stream ids

TYPE: List[str]

stop()

Stops the function and disconnects from the output streams