dnvriend / akka-persistence-inmemory

Akka-persistence-inmemory is a plugin for akka-persistence that stores journal and snapshot messages memory, which is very useful when testing persistent actors, persistent FSM and akka cluster
Apache License 2.0
134 stars 41 forks source link

Adds support for keyspace similar to akka-persistence-cassandra #39

Closed BeatSager closed 6 years ago

BeatSager commented 7 years ago

In our product we use this great plugin as well when we start up the developers local servers. We have many applications running store their data in deployed environment in different cassandra keyspaces. In order to test all this applications together we need this feature as well local in memory.

dnvriend commented 6 years ago

Hi, interesting PR. Could you please elaborate some more on the design?

BeatSager commented 6 years ago

Hi,

in akka-persistence-cassandra all cassandra keyspaces are completely independent. I added this behavior to get a StorageExtension for each configured keyspace. That's it.

Modifications in detail:

Guarantee that multiple lookups for the same keyspace always provide the same StorageExtension. This is accomplished by having a map of storages instead of a singleton providing that one storage. The existing implementation would provide a storage for each JVM.

Fixed concurrency issue introduced by using this map with the additional commit.

Provide an extractor function StorageExtension#keyspaceFrom(config: Config) to get the keyspace according the akka config.

Pass the keyspace to the StorageExtension.

Instead of using the journal directly in all helper functions of the QueryTestSpec, it is passed and defined implicitly.

New test which provides explicitly a journal with some keyspace

dnvriend commented 6 years ago

Hi, is this still a relevant PR?

BeatSager commented 6 years ago

Yes we use the feature this pr provides in our company. Would be great to have that merged.

dnvriend commented 6 years ago

What if the storageextension could be pluggable, this way a project that has a different storage extension impl requirement could configure the fqcn in typesafe config just like with the inmemory journal typesafe config L17. This way the class could look up and instantiate the appropriate storage extension L32

Could you please look into that and fix the PR so that it can be merged? That way my concern of having specific implementations have been addressed.

dnvriend commented 6 years ago

The StorageExtensionImpl should be pluggable of course, and in its own class and have its own configutation. What are your thoughts?

BeatSager commented 6 years ago

I think this would be a good solution. Currently I have not enough time to work on that, but will do it in about 2 weeks.

BeatSager commented 6 years ago

Replaced by https://github.com/dnvriend/akka-persistence-inmemory/pull/59