From bf0e41f6c86b39acd5790ab480fefd64adb3ec9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Zimmermann?= <101292599+ekneg54@users.noreply.github.com> Date: Fri, 12 Jan 2024 20:39:15 +0100 Subject: [PATCH] add do nothing option to dummy output (#503) * add do nothing option to dummy output --- CHANGELOG.md | 1 + logprep/abc/output.py | 3 +++ logprep/connector/dummy/output.py | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73f9a8dd9..c4c6d9bae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ ### Improvements +* a do nothing option do dummy output to ensure dummy does not fill memory * make the s3 connector raise `FatalOutputError` instead of warnings * make the s3 connector blocking by removing threading diff --git a/logprep/abc/output.py b/logprep/abc/output.py index fc09e5a0b..18d771f4c 100644 --- a/logprep/abc/output.py +++ b/logprep/abc/output.py @@ -93,3 +93,6 @@ def store_custom(self, document: dict, target: str): @abstractmethod def store_failed(self, error_message: str, document_received: dict, document_processed: dict): """Store an event when an error occurred during the processing.""" + + def _write_backlog(self): + """Write the backlog to the output destination.""" diff --git a/logprep/connector/dummy/output.py b/logprep/connector/dummy/output.py index 55830a1f2..4711c4a75 100644 --- a/logprep/connector/dummy/output.py +++ b/logprep/connector/dummy/output.py @@ -37,6 +37,8 @@ class DummyOutput(Output): class Config(Output.Config): """Common Configurations""" + do_nothing: bool = field(default=False) + exceptions: List[str] = field( validator=validators.deep_iterable( member_validator=validators.instance_of((str, type(None))), @@ -83,6 +85,8 @@ def store(self, document: dict): document : dict Processed log event that will be stored. """ + if self._config.do_nothing: + return if self._exceptions: exception = self._exceptions.pop(0) if exception is not None: @@ -98,6 +102,8 @@ def store_custom(self, document: dict, target: str): def store_failed(self, error_message: str, document_received: dict, document_processed: dict): """Store an event when an error occurred during the processing.""" + if self._config.do_nothing: + return self.metrics.number_of_failed_events += 1 self.failed_events.append((error_message, document_received, document_processed))