Initial implementation of Redis Streams. by ttingen · Pull Request #860 · StackExchange/StackExchange.Redis

NickCraver

previously requested changes Jun 26, 2018

NickCraver

The Streams data type is available in releases 5.0 RC1 and above.

- Implemented Sync & Async methods for all Stream related commands (minus the blocking options) as of 5.0 RC1:
    XACK,
    XADD,
    XCLAIM,
    XDEL,
    XGROUP,
    XINFO,
    XLEN,
    XPENDING,
    XRANGE,
    XREAD,
    XREADGROUP,
    XREVRANGE,
    XTRIM
- Added tests for the synchronous versions of the Streams API but the testing is a work in progress. Need to refactor for reuse within the streams tests and write a thorough suite of tests.
- Added a NameValueEntry struct which mimicks HashEntry. Using HashEntry for the name/value pairs of stream entries seemed wrong. Perhaps refactor the usage of HashEntry to the more generic NameValueEntry and deprecate HashEntry?
- Cleaned up some comments in the test suite.
- Added two new tests (StreamReadMultipleStreamsWithCount & StreamConsumerGroupClaimMessagesReturningIds).
- Updated the XML docs on NameValueEntry to remove the old references to HashEntry.

@ttingen

@ttingen

…alue, makes it more intuitive.
…reamInfoGet.

StreamInfoGet can return a null value for FirstEntry and LastEntry if the stream has no entries.
- Added overload to GetStreamAcknowledgeMessage method to receive a single messageId instead of an array.
- Added overload to GetStreamAddMessage to receive a single NameValueEntry instead of an array.
- Corrected the constructor usage of ArgumentOutOfRangeException.
- Converted to get-only properties on RedisStream and other structs.
- Converted some classes to structs (StreamInfo, StreamGroupInfo, etc.)
- Miscellaneous cleanup in ResultProcessor.cs & convert many for loops to Array.ConvertAll.
- Renamed StreamMinValue and StreamMaxValue to ReadMinValue and ReadMaxValue.
- Renamed streamFields input variable on several methods to streamPairs.
- Updated XML docs (ID's to IDs).
- Reverted changes to the Tests csproj file.
- Updated the type for messageId from string to RedisValue.
- Collapsed several overloads.
- Updated the method order in several places to follow the sync/async pattern.
- Added more tests.
- Miscellaneous cleanup.

Signed-off-by: ttingen <ttingen@gmail.com>

@ttingen

@ttingen

Also some additional cleanup.

@ttingen

- Removed 4 StreamAdd overloads.
- Renamed streamEntryId to messageId and defaulted it to "*" (auto-generated ID).
- Added a StreamIdPair struct and updated one of the StreamRead overloads to use it.
- messageId on StreamAdd methods was changed from string to RedisValue? and is defaulted to null. When null, the API will send the auto-generated ID option ("*").
- StreamConstants accessibility was updated from public to internal.
- minId & maxId input parameters were updated to be of type RedisValue?, sends StreamConstants.ReadMinValue & StreamConstants.ReadMaxValue when null.
- readFromId on StreamCreateConsumerGroup updated to type RedisValue?, sends StreamConstants.NewMessages when null.
- readFromId on StreamReadGroup updated to type RedisValue?, sends StreamConstants.UndeliveredMessages when null.

@ttingen

NickCraver