Giter Site home page Giter Site logo

epiphyllum / akka-persistence-query-test Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dnvriend/akka-persistence-query-test

0.0 2.0 0.0 16 KB

A small study project on the akka-persistence-query API as there is no TCK

License: Apache License 2.0

Scala 100.00%

akka-persistence-query-test's Introduction

akka-persistence-query-test

Study on the akka-persistence-query API. As there is no Technology Compatibility Kit (TCK) as of yet for akka-persistence-query, I will be looking at the leveldb implementation that comes out of the box with akka and assert the behavior so that I can replicate it in the akka-persistence-inmemory and akka-persistence-jdbc plugins.

Conclusions

The following are my findings.

CurrentPersistenceIds API

  • Empty journal: Apparently the leveldb query API is magical, with an empty journal (no events), it still can determine the persistenceIds of any running persistent actor, this is something that cannot be reproduced with the inmemory plugin or the jdbc plugin,
  • The emitted element type is String,
  • PersistenceIds, are streamed in a non-deterministic order,
  • PersistenceIds are emitted only once, so the API is stateful.

EventsByPersistenceIds

final case class EventEnvelope(
  offset:        Long,
  persistenceId: String,
  sequenceNr:    Long,
  event:         Any)
  • The EventEnvelope has a field called offset which is kind of confusing. With the eventsByPersistenceIds, the offset value is the same as the event sequenceNr. This behavior is different from the byTag queries.
  • Using the from/to sequenceNr fields in the query, the following table applies when there are three events:
from to result
0 1 EventEnvelope(1, persistenceId, 1, event)
1 1 EventEnvelope(1, persistenceId, 1, event)
1 2 EventEnvelope(1, persistenceId, 1, event), EventEnvelope(2, persistenceId, 2, event)
2 2 EventEnvelope(2, persistenceId, 2, event)
2 3 EventEnvelope(2, persistenceId, 2, event), EventEnvelope(3, persistenceId, 3, event)
3 3 EventEnvelope(3, persistenceId, 3, event)
0 3 EventEnvelope(1, persistenceId, 1, event), EventEnvelope(2, persistenceId, 2, event), EventEnvelope(3, persistenceId, 3, event)
1 3 EventEnvelope(1, persistenceId, 1, event), EventEnvelope(2, persistenceId, 2, event), EventEnvelope(3, persistenceId, 3, event)

EventsByPersistenceId should terminate when the toSequenceNr has been reached. Also, but not implemented by the levelDb journal, it should also terminate when the toSeqnr is equal to zero (0)

EventsByTag API

  • The emitted element is akka.persistence.query.EventEnvelope,
  • The field offset is a generated number that is added to the event stream that tags that emitted event with a unique number for that query,
  • Using the offset field in the query, the following table applies when three events match the query:
offset result
0 EventEnvelope(1, _, _, _), EventEnvelope(2, _, _, _), EventEnvelope(3, _, _, _)
1 EventEnvelope(1, _, _, _), EventEnvelope(2, _, _, _), EventEnvelope(3, _, _, _)
2 EventEnvelope(2, _, _, _), EventEnvelope(3, _, _, _)
3 EventEnvelope(3, _, _, _)
4 No events are emitted

What's new?

1.0.0 (2016-06-09)

  • Initial

Have fun!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.