Island: Add save_event_to_event_repository subscriber

This commit is contained in:
Ilija Lazoroski 2022-09-14 17:17:32 +02:00
parent bb0910371c
commit 26fc6fd5b9
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1 @@
from .save_event_to_event_repository import save_event_to_event_repository

View File

@ -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}")