Skip to content

Commit 872722b

Browse files
committed
redis eventpublisher first cut [redis_eventpublisher_first_cut]
1 parent 7023466 commit 872722b

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import json
2+
import logging
3+
from dataclasses import asdict
4+
import redis
5+
6+
from allocation import config
7+
from allocation.domain import events
8+
9+
logger = logging.getLogger(__name__)
10+
11+
r = redis.Redis(**config.get_redis_host_and_port())
12+
13+
14+
def publish(channel, event: events.Event):
15+
logging.debug("publishing: channel=%s, event=%s", channel, event)
16+
r.publish(channel, json.dumps(asdict(event)))

0 commit comments

Comments
 (0)