This repository was archived by the owner on Aug 15, 2024. It is now read-only.
Allow stream message json data to not be prefetched during stream reading. - #49
Merged
Merged
Conversation
Member
Author
|
Note: I'd like to separately support reads that allow server side of filtering by |
damianh
commented
Nov 7, 2016
|
|
||
| message.MessageId.ShouldBe(expectedMessage.MessageId); | ||
| message.JsonData.ShouldBe(expectedMessage.JsonData); | ||
| (await message.GetJsonData()).ShouldBe(await expectedMessage.GetJsonData()); |
Member
Author
There was a problem hiding this comment.
This is the main breaking change for consumers.
damianh
commented
Nov 7, 2016
| Task<ReadAllPage> ReadAllForwards( | ||
| long fromPositionInclusive, | ||
| int maxCount, | ||
| bool prefetchData = true, |
Member
Author
There was a problem hiding this comment.
The additional optional parameter.
damianh
commented
Nov 7, 2016
| private readonly Func<int> _getNextPosition; | ||
| private readonly List<InMemoryStreamMessage> _events = new List<InMemoryStreamMessage>(); | ||
| private readonly Dictionary<Guid, InMemoryStreamMessage> _eventsById = new Dictionary<Guid, InMemoryStreamMessage>(); | ||
| private readonly List<InMemoryStreamMessage> _messages = new List<InMemoryStreamMessage>(); |
Member
Author
There was a problem hiding this comment.
Took the opportunity to clean up when I saw it.
… ReadStreamForwards to prefetch the json data.
…eadStreamBackward.
…essage has been deleted.
damianh
force-pushed
the
async-json-data
branch
from
November 7, 2016 21:56
fbe98ac to
3103250
Compare
Member
Author
|
I should add, one of the other drivers of this was the HTTP API where we want to be able to GET streams with links to individual message json data (as opposed to embedding it). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When reading a stream (or all) you may not be interested in the
JsonDatapayload of every single message. As there is currently no limit on the size of theJsonDatapayload in the core (limitation is store specific), this PR allows the user to disable prefetching of that JsonDataThe key changes are:
IReadOnlyStreamStore.ReadAllForwards(),.ReadAllBackwards(),.ReadStreamForwards(),.ReadStreamBackwards()all have an additional, optional parameterprefetchJsonData = true.StreamMessage.JsonData {get;}property has been replaced with a methodTask<string> StreamMessage.GetJsonData(). When prefetch is turned off this will result will result in a call to the server.InMemoryStreamStoresimulates the async nature using a task offload if prefetching is turned off.Note there is a condition where the message may be deleted between handling a
StreamMessageinstance and calling theGetJsonData(). The implementation here is to return a null when that occurs.This is a breaking change.