-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathdatafeed.py
More file actions
36 lines (26 loc) · 1.2 KB
/
Copy pathdatafeed.py
File metadata and controls
36 lines (26 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import asyncio
import logging.config
from pathlib import Path
from symphony.bdk.core.config.loader import BdkConfigLoader
from symphony.bdk.core.service.datafeed.real_time_event_listener import RealTimeEventListener
from symphony.bdk.core.symphony_bdk import SymphonyBdk
from symphony.bdk.gen.agent_model.v4_initiator import V4Initiator
from symphony.bdk.gen.agent_model.v4_message_sent import V4MessageSent
async def run():
config = BdkConfigLoader.load_from_symphony_dir("config.yaml")
async with SymphonyBdk(config) as bdk:
datafeed_loop = bdk.datafeed()
datafeed_loop.subscribe(RealTimeEventListenerImpl())
await datafeed_loop.start()
class RealTimeEventListenerImpl(RealTimeEventListener):
async def on_message_sent(self, initiator: V4Initiator, event: V4MessageSent):
# We do not recommend logging full events in production as it could expose sensitive data
logging.debug("Received event: %s", event)
logging.config.fileConfig(
Path(__file__).parent.parent / "logging.conf", disable_existing_loggers=False
)
try:
logging.info("Running datafeed example...")
asyncio.run(run())
except KeyboardInterrupt:
logging.info("Ending datafeed example")