Add document loaded/addedForStorage interception methods#200
Conversation
|
@tim-cools Maybe I'm wrong but I think you could write a decorator and reuse it for all IdentityMap's |
|
@ekulakov thanks for the feedback!This is however not possible because the listeners are only called when a document is loaded the first time and not when the document is returned from the cache. tim-cools@306bb17#diff-99cac1569732f4ed1d27aceb9e8f52ebR64 A decorator is unaware of the internals of the decorated class. We might consider pulling out a generic base class for both IdentityMaps however. I will look into that later... |
| public IdentityMap(ISerializer serializer, IEnumerable<IDocumentSessionListener> listeners) | ||
| { | ||
| _serializer = serializer; | ||
| _listeners = listeners?.Any() == true ? listeners : null; |
There was a problem hiding this comment.
@tim-cools I'd rather we used a "nullo" empty list here instead of having to remember to always use the "?" operator. Nit pick-y, I know.
There was a problem hiding this comment.
no problem, will update it in a next pull request. it was a silly attempt of premature optimization...
|
I've got a minor comment about using a nullo for the list of listeners, but other than that I think this looks good. The build passed, and I'm pulling this in now. |
…orage-interception-methods Add document loaded/addedForStorage interception methods
Picks up the fix for CultureNotFoundException at DocumentStore..ctor on hosts running with <InvariantGlobalization>true</InvariantGlobalization> (JasperFx PR #200): the cold-start prefilter in ProjectionGraph.IsAssemblyKnownToHaveNoEvolvers was crashing on satellite assemblies with culture identities like 'pt-br'. Companion of Marten 8.34.1 release.
I added two methods to the IDocumentSessionListener to intercept when documents are loaded/stored.
void DocumentLoaded(object id, object document);
void DocumentAddedForStorage(object id, object document);
This interception is currently implemented in the default and DirtyChecking IdentityMap.
I was tempted to split the IDocumentSessionListener into a IDocumentSessionListener and IDocumentListener. The latter would contain the new methods. But I decided to go for the simplest implementation for now. Let me know what your thoughts are about this?
If you agree I can add this also to the documentation if you want.