Skip to content

Commit

Permalink
add do nothing option to dummy output (#503)
Browse files Browse the repository at this point in the history
* add do nothing option to dummy output
  • Loading branch information
ekneg54 authored Jan 12, 2024
1 parent 74623ce commit bf0e41f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions logprep/abc/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
6 changes: 6 additions & 0 deletions logprep/connector/dummy/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
Expand Down Expand Up @@ -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:
Expand All @@ -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))

Expand Down

0 comments on commit bf0e41f

Please sign in to comment.