esppy.windows.Publisher

class esppy.windows.Publisher(window, blocksize=1, rate=0, pause=0, dateformat='%Y%m%dT%H:%M:%S.%f', opcode='insert', format='csv', separator=None)

Bases: object

Create a publisher for the given window

Parameters
windowWindow

The window object to create the subscriber for

blocksizeint, optional

Number of events to put into an event block

rateint, optional

Maximum number of events to inject per second

pauseint, optional

Number of milliseconds to pause between each injection of events

dateformatstring, optional

Format for date fields

opcodestring, optional

Opcode to use if an input event does not include one: ‘insert’, ‘upsert’, ‘delete’

formatstring, optional

The data format of inputs: ‘csv’, ‘xml’, ‘json’, ‘properties’

separatorstring

The separator string to use between events in ‘properties’ format

Returns
Publisher

Examples

Create the publisher instance using CSV and an event rate of 200 events per millisecond.

>>> pub = Publisher(window, rate=200)

Send the CSV data.

>>> pub.send('1,2,3')

Close the connection.

>>> pub.close()
Attributes
blocksizeint

Number of events to put into an event block

dateformatstring

Format for date fields

formatstring

The data format of inputs: ‘csv’, ‘xml’, ‘json’, ‘properties’

is_activebool

Is the web socket active?

opcodestring

Opcode to use if an input event does not include one: ‘insert’, ‘upsert’, ‘delete’

pauseint

Number of milliseconds to pause between each injection of events

rateint

Maximum number of events to inject per second

separatorstring

The separator string to use between events in ‘properties’ format

window_schemaSchema

The schema of the window that was subscribed to

window_urlstring

The publisher URL of the window

__init__(self, window, blocksize=1, rate=0, pause=0, dateformat='%Y%m%dT%H:%M:%S.%f', opcode='insert', format='csv', separator=None)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self, window[, blocksize, rate, …])

Initialize self.

close(self)

Close the web socket connection

send(self, data)

Send data to the web socket

Attributes

is_active

Is the web socket active?

url

Return the URL of the subscriber