Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistence "model adapter" for separating models and upcasting #17579

Closed
ktoso opened this issue May 27, 2015 · 7 comments
Closed

Persistence "model adapter" for separating models and upcasting #17579

ktoso opened this issue May 27, 2015 · 7 comments
Assignees
Milestone

Comments

@ktoso
Copy link
Member

ktoso commented May 27, 2015

Add a "man in the middle" between PersistentActor and the Journal which can be used to.

No API is yet decided, first we'll need to draft a few example impls.

Use cases this adapter should cover (possibly all, or we split it up, not sure yet):

    "domain model to data model" case
                                       +---------+
+---------+     domain => BSON         | journal |
|persist()+---------------------------->         |
+---------+                            |         |
                                       |         |
           <---------------------------+         |
              BSON => domain           |         |
                                       |         |
                                       +---------+

    "upcasting events" case

+                                  +---------+
<----------------------------------+ journal |
|     model-v1 => [0..n] model-v2  |         |
|                                  |         |
|                                  +---------+
+                                      

  • provide a place where event upcasting on recovery could be performed
    • figure out if/how/which we support: bytes => logic => upcasted event and/or old-model => upcasted-model
    • some inspiration to be gained from [http://www.axonframework.org/docs/2.4/single.html#event-upcasting](Axon upcasters)
    • upcasting may require 1 "v1 event" to emit more than 1 "v2 event", example is when migrating from ClientDetailsChanged to AddressChanged + PersonalDataChanged
  • if not needed, it should be an identity pass through by default
    • if needed by the Journal, the user must configure it in code - as it's a function and could be combined based on some logic with more upcasters (e.g. when I have "domain-module-a" and "domain-module-b" and both provide adapters for their classes)
    • if needed, and not configured the journal should throw exceptions eagerly
                domain-event                          
                    =>                 +---------+
+---------+     tagged(domain-event)   | journal |
|persist()+---------------------------->         |
+---------+                            |         |
                                       |         |
                                       |         |
                                       |         |
                                       |         |
                                       +---------+

  • additional: since tagging is also journal specific, some journals need it and some not, this seems to be a good place to encourage to use for tagging as well, as it's bound to the journal, and gets the event so it can extract tags
@ktoso ktoso added this to the 2.4-M2 milestone May 27, 2015
@ktoso ktoso added the 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted label May 27, 2015
@ktoso ktoso added the large label May 27, 2015
@olger
Copy link

olger commented May 28, 2015

Could explain a bit what in 'identity pass through by default' the identity is ?

@olger
Copy link

olger commented May 28, 2015

Is the basic idea to use BSON for the payload serialisation ? It seems that at this moment that protobuf is part of the serialisation. Should that be removed ?

@ktoso
Copy link
Member Author

ktoso commented May 28, 2015

BSON is just an example, inspired by the issue linked above (the mongodb journal), it could be any format that the journal plugin understands. It could also be that the adapter just passes the object through, and the journal plugin performs the serializaiton inside.

ktoso referenced this issue in EventStore/EventStore.Akka.Persistence May 29, 2015
@ktoso
Copy link
Member Author

ktoso commented May 29, 2015

Closing this ticket, we decided that serializers are powerful enough to express all migrations we need.

Will be replaced by:

@ahjohannessen
Copy link

@ktoso I like the ideas you have lined up above. What do you mean by come back of Tagger ?

ktoso added a commit to ktoso/akka that referenced this issue Jun 1, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
- todo not happy yet with initialization (message)?
+ adapters work both ways
+ tests show "tagging"
@ktoso
Copy link
Member Author

ktoso commented Jun 1, 2015

By Tagger I meant an additional facility which can be asked to extract metadata about a given event. More info on it in #17617.

However after a few drafts of adapters and taggers we're back to adapters - they're more powerful and can do the generic "I want to separate data from domain completely" in a nice way, PR coming up right now.

@ktoso ktoso added 3 - in progress Someone is working on this ticket and removed 1 - triaged Tickets that are safe to pick up for contributing in terms of likeliness of being accepted labels Jun 1, 2015
@ahjohannessen
Copy link

@ktoso Cool stuff, I think this will make a difference 👍 Secondary indexes by event type / category is probably the most wanted feature in akka persistence and I think this will make it easier for journals like the eventstore to utilize their built-in features, e.g. projections by event type, without workarounds and custom hacks :)

ktoso added a commit to ktoso/akka that referenced this issue Jun 2, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
- todo not happy yet with initialization (message)?
+ adapters work both ways
+ tests show "tagging"
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
- todo not happy yet with initialization (message)?
+ adapters work both ways
+ tests show "tagging"
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jun 22, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jun 23, 2015
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit that referenced this issue Jun 24, 2015
@ktoso ktoso removed the 3 - in progress Someone is working on this ticket label Jun 24, 2015
@ktoso ktoso self-assigned this Jun 24, 2015
@ktoso ktoso closed this as completed Jun 24, 2015
ktoso added a commit to ktoso/akka that referenced this issue Jan 11, 2016
+ per plugin scoped adapters
+ could be swapped during runtime
+per EventAdapter now has manifest and is configurable ai la serializers
+ json examples in docs
+ including "completely manual" example in case one wants to add
  metadata TO the persisted event
+ better error reporting when misconfigured bindings
+ manifest is handled by in memory plugin
- did not check if it works with LevelDB plugin yet
> TODO: json example uses Gson, as that's simplest to do, can we use
+per allows 1:n adapters, multiple adapters can be bound to 1 class
ktoso added a commit to ktoso/akka that referenced this issue Jan 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants