Skip to content

Latest commit

 

History

History
87 lines (55 loc) · 4.22 KB

README.md

File metadata and controls

87 lines (55 loc) · 4.22 KB

FoundationDb Plugins for Akka Persistence

Replicated Akka Persistence journal and snapshot store backed by FoundationDB.

Dependencies

Latest release

This version of akka-persistence-foundationdb depends on Akka 2.6.13 and Foundation 6.2.x. It has been published for Scala 2.13.5.

Journal plugin

Features

  • All operations required by the Akka Persistence journal plugin API are fully supported.
  • Persistence Query support by FoundationDbReadJournal
  • Extra safe mode which disallows concurrent event writes and journal corruption is enabled by default.
  • Fast and efficient deletions (takes O(log(n)) time)
  • Two ways to store tags: compact (just a reference to the event journal, uses less space but requires an extra fetch query) or high-performance (a copy of the event with all required data, will consume 2x space however it's extremely fast). It's also possible to switch the tag type at any time. Choose based on your needs!

Configuration

To activate the journal plugin, add the following line to your Akka application.conf:

akka.persistence.journal.plugin = "foundationdb-journal"

This will run the journal with its default settings. The default settings can be changed with the configuration properties defined in reference.conf:

Caveats

  • Detailed tests under failure conditions are still missing.
  • Some tests are still missing.
  • Snapshot size can't be more than 10mb. It's going to be resolved in a future releases.

These issues are likely to be resolved in future versions of the plugin.

Limitations

  • Due to FoundationDB limitations, your event and all tags can't be more than 10mb (actually less, since 10mb is a transaction limit). If you find yourself saving more than 10mb in one transaction, please consider splitting your events.

Event deletion

Please keep in mind that event deletion has a different behavior depending on tag types. If you use compact tags, then tag is a reference to your event. If you delete the event from the journal, tag will point to the empty event and will be automatically cleared at the next eventsByTag query call. At the other hand, if your tag is rich, it will contain the whole event and won't be deleted, so your eventsByTag query will work as expected.

Snapshot store plugin

Features

Configuration

To activate the snapshot-store plugin, add the following line to your Akka application.conf:

akka.persistence.snapshot-store.plugin = "foundationdb-snapshot-store"

This will run the snapshot store with its default settings. The default settings can be changed with the configuration properties defined in reference.conf:

Persistence Queries

It implements the following Persistence Queries:

  • currentPersistenceIds, (persistenceIds is not implemented yet)
  • eventsByPersistenceId, currentEventsByPersistenceId
  • eventsByTag, currentEventsByTag

All live queries are implemented using database push mechanism and don't use polling. It allows very low latencies between the writing event to the journal and it's replication to the query side.

Persistence Query usage example to obtain a stream with all events tagged with "someTag" with Persistence Query:

val queries = PersistenceQuery(system).readJournalFor[FoundationDbReadJournal](FoundationDbReadJournal.Identifier)
queries.eventsByTag("someTag", Offset.noOffset)

Compared to other journals, there are no hard limits regarding the amount of tags per event. It's been tested to work with 1000 tags per event.