The modifier API would provide a hook for extension authors to modify an event in-place before it is validated and emitted.
A modifier would a be callable that would take the raw event data, modify it in-place, and return the modified version.
def modifier(event_data: dict) -> dict:
...
The immediate use-case for the modifier API would be to apply "redactors" to the EventLogger that remove properties from the event before they were emitted.
The EventLogger would need a new method to add these modifiers, e.g.
class EventLogger(...):
...
def add_modifier(self, modifier: Callable[[dict], dict]):
# Adds modifier to list of modifiers
...
def emit(self, ..., data: dict, ...):
# Should modify the data in-place.
for modifier in self._modifiers:
data = modifier(data)
# Validate after. Ensures that validators return a valid schema to emit.
self.validate(..., data)
# Emit the event
self.emit(...)
The modifier API would provide a hook for extension authors to modify an event in-place before it is validated and emitted.
A modifier would a be callable that would take the raw event data, modify it in-place, and return the modified version.
The immediate use-case for the modifier API would be to apply "redactors" to the
EventLogger
that remove properties from the event before they were emitted.The
EventLogger
would need a new method to add these modifiers, e.g.The public API would look something like: