Skip to content

Commit 5f91cca

Browse files
committed
use bootstrap for redis
1 parent 8b3eeed commit 5f91cca

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/allocation/entrypoints/redis_eventconsumer.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,29 @@
22
import logging
33
import redis
44

5-
from allocation import config
5+
from allocation import bootstrap, config
66
from allocation.domain import commands
7-
from allocation.adapters import orm
8-
from allocation.service_layer import messagebus, unit_of_work
97

108
logger = logging.getLogger(__name__)
119

1210
r = redis.Redis(**config.get_redis_host_and_port())
1311

1412

13+
1514
def main():
16-
orm.start_mappers()
15+
bus = bootstrap.bootstrap()
1716
pubsub = r.pubsub(ignore_subscribe_messages=True)
1817
pubsub.subscribe('change_batch_quantity')
1918

2019
for m in pubsub.listen():
21-
handle_change_batch_quantity(m)
20+
handle_change_batch_quantity(m, bus)
2221

2322

24-
def handle_change_batch_quantity(m):
23+
def handle_change_batch_quantity(m, bus):
2524
logging.debug('handling %s', m)
2625
data = json.loads(m['data'])
2726
cmd = commands.ChangeBatchQuantity(ref=data['batchref'], qty=data['qty'])
28-
messagebus.handle(cmd, uow=unit_of_work.SqlAlchemyUnitOfWork())
27+
bus.handle(cmd)
2928

3029

3130
if __name__ == '__main__':

0 commit comments

Comments
 (0)