symphony.bdk.core.service.datafeed.datafeed_loop_v1.DatafeedLoopV1#

class symphony.bdk.core.service.datafeed.datafeed_loop_v1.DatafeedLoopV1(datafeed_api, session_service, auth_session, config, repository=None)#

Bases: symphony.bdk.core.service.datafeed.abstract_datafeed_loop.AbstractDatafeedLoop

A class for implementing the datafeed v1 loop service.

This service will be started by calling start().

On the very first run, the datafeed will be created and the BDK bot will listen to this datafeed to receive real-time events. With datafeed service v1, we don’t have the api endpoint to retrieve the datafeed id that a service account is listening to, so, the id of the created datafeed must be persisted in the bot side.

The BDK bot will listen to this datafeed to get all the received real-time events.

On another run, the bot will firstly retrieve the datafeed that was persisted and try to read the real-time events from this datafeed. If this datafeed is expired or faulty, the datafeed service will create the new one for listening.

This service will be stopped by calling stop()

If the datafeed service is stopped during a read datafeed call, it has to wait until the last read finish to be really stopped

__init__(datafeed_api, session_service, auth_session, config, repository=None)#
Parameters
  • datafeed_api – DatafeedApi to request the service

  • session_service – the SessionService to get user session information

  • auth_session – the AuthSession instance used to get session and key manager tokens

  • config – the bot configuration

Methods

__init__(datafeed_api, session_service, ...)

param datafeed_api

DatafeedApi to request the service

recreate_datafeed()

start()

Start the datafeed event service

stop([hard_kill, timeout])

Stop the datafeed event service

subscribe(listener)

Subscribes a new listener to the datafeed loop instance.

unsubscribe(listener)

Removes a given listener from the datafeed loop instance.

async start()#

Start the datafeed event service

Returns

None

async stop(hard_kill: bool = False, timeout: Optional[float] = None)#

Stop the datafeed event service

Parameters
  • hard_kill – if set to True, tasks running listener methods will be cancelled immediately. Otherwise, tasks will be awaited until completion.

  • timeout – timeout in seconds to wait for tasks completion when loop stops. None means wait until completion. Ignored if hard_kill set to True.

Returns

None

subscribe(listener: symphony.bdk.core.service.datafeed.real_time_event_listener.RealTimeEventListener)#

Subscribes a new listener to the datafeed loop instance.

Parameters

listener – the RealTimeEventListener to be added.

unsubscribe(listener: symphony.bdk.core.service.datafeed.real_time_event_listener.RealTimeEventListener)#

Removes a given listener from the datafeed loop instance.

Parameters

listener – the RealTimeEventListener to be removed.