Island: Add save_event_to_event_repository subscriber
This commit is contained in:
parent
bb0910371c
commit
26fc6fd5b9
|
@ -0,0 +1 @@
|
||||||
|
from .save_event_to_event_repository import save_event_to_event_repository
|
|
@ -0,0 +1,17 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from common.events import AbstractAgentEvent
|
||||||
|
from monkey_island.cc.repository import IEventRepository, StorageError
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class save_event_to_event_repository:
|
||||||
|
def __init__(self, event_repository: IEventRepository):
|
||||||
|
self._event_repository = event_repository
|
||||||
|
|
||||||
|
def __call__(self, event: AbstractAgentEvent):
|
||||||
|
try:
|
||||||
|
self._event_repository.save_event(event)
|
||||||
|
except StorageError as err:
|
||||||
|
logger.error(f"Error occured storing event {event}: {err}")
|
Loading…
Reference in New Issue