Bump up patch version 2.0.4
[pti/o2.git] / o2app / bootstrap.py
index 7a074f6..7679ef3 100644 (file)
@@ -17,16 +17,18 @@ import inspect
 from typing import Callable
 
 from o2common.adapter.notifications import AbstractNotifications,\
-    SmoO2Notifications
+    NoneNotifications
 from o2common.adapter import redis_eventpublisher
 from o2common.service import unit_of_work
+from o2common.service import messagebus
 
-from o2app.service import handlers, messagebus
+from o2app.service import handlers
 from o2app.adapter.unit_of_work import SqlAlchemyUnitOfWork
 
 from o2ims.adapter import orm as o2ims_orm
 from o2dms.adapter import orm as o2dms_orm
 
+
 from o2common.helper import o2logging
 logger = o2logging.get_logger(__name__)
 
@@ -47,12 +49,13 @@ def bootstrap(
 ) -> messagebus.MessageBus:
 
     if notifications is None:
-        notifications = SmoO2Notifications()
+        notifications = NoneNotifications()
 
     if start_orm:
         with uow:
             # get default engine if uow is by default
             engine = uow.session.get_bind()
+
             wait_for_db_ready(engine)
             o2ims_orm.start_o2ims_mappers(engine)
             o2dms_orm.start_o2dms_mappers(engine)
@@ -71,11 +74,13 @@ def bootstrap(
         for command_type, handler in handlers.COMMAND_HANDLERS.items()
     }
 
-    return messagebus.MessageBus(
+    bus = messagebus.MessageBus(
         uow=uow,
         event_handlers=injected_event_handlers,
         command_handlers=injected_command_handlers,
     )
+    messagebus.MessageBus.set_instance(bus)
+    return bus
 
 
 def inject_dependencies(handler, dependencies):