I’m currently trying to implement encryption of persisted events in my application. I’ve read the docs on creating custom serializers here: https://doc.akka.io/docs/akka/current/serialization.html but there is no information on how or what creates new serializer instances or how transient they are (does an actor system only ever create one instance per type or does it have a pool of them?).
I’m currently working on the assumption that a custom serializer implementation can not be passed anything other than a
ExtendedActorSystem parameter (though if I could pass in other parameters it would be a big help).
So my current implementation required the serializer to look-up an actor ref and message an actor to retrieve the correct encryption key. This though leads me to have to use the
Await construct as the
fromBinary methods are synchronous.
Does anyone have/know a ‘better way’ of providing persistence serializers with encryption keys? I have seen that Lightbend have a GdprEncryption module as part of their ‘Akka Enhancements’ (https://doc.akka.io/docs/akka-enhancements/current/gdpr/encryption.html#gdprencryption) but alas I don’t have access to those so its DIY time.