Why?
There is a problem with the current sequence of event processing in the repository (load->serialize->anonymize? / anonymize?->serialize->save) which blocks the anonymization of the transport model. As of now the anonymizer has access to the original stream model only, considered a central, domain model with advanced implementation. Given that the anonymization is based on reflection there may be multiple edge cases (protected, complex or third-party type to name a few) where anonymization of a domain model will not be possible.
What?
In order to solve the problem described above and force the library users to use and define anonymization in their transport models I did the following:
Split domain-transport mapping from the marshaling. Now components responsible for each of the two are configured separately. Instead of a Serializer, we now have a transport.Mapper and transport.Marshaler. As a special implementation of a Mapper, there is an AESAnonymizer that wraps any implementation of a mapper with anonymization capabilities.
There are three implementations of transport.Mapper interface:
-- transport.NoOpMapped - using original events as transport models,
-- transport.DefaultMapper - using a defined list of registered transport models transport.Event[T] defining mapping logic from- and to- stream.Event[T] which, in my opinion, simplifies the API and improves the DX significantly.
-- transport.AESAnonymizer - wrapper mentioned above.
Tests
I kept the existing tests with all possible combinations of configurations.
Why? There is a problem with the current sequence of event processing in the repository (
load->serialize->anonymize?
/anonymize?->serialize->save
) which blocks the anonymization of the transport model. As of now the anonymizer has access to the originalstream
model only, considered a central, domain model with advanced implementation. Given that the anonymization is based on reflection there may be multiple edge cases (protected, complex or third-party type to name a few) where anonymization of a domain model will not be possible.What? In order to solve the problem described above and force the library users to use and define anonymization in their transport models I did the following:
Serializer
, we now have atransport.Mapper
andtransport.Marshaler
. As a special implementation of aMapper
, there is anAESAnonymizer
that wraps any implementation of a mapper with anonymization capabilities.transport.Mapper
interface: --transport.NoOpMapped
- using original events as transport models, --transport.DefaultMapper
- using a defined list of registered transport modelstransport.Event[T]
defining mapping logic from- and to-stream.Event[T]
which, in my opinion, simplifies the API and improves the DX significantly. --transport.AESAnonymizer
- wrapper mentioned above.Tests I kept the existing tests with all possible combinations of configurations.