public static GetCursors ( string cursor, string prefix ) : List |
||
cursor | string | |
prefix | string | |
return | List |
public ScaleoutSubscription(string identity, IList <string> eventKeys, string cursor, IList <ScaleoutMappingStore> streams, Func <MessageResult, object, Task <bool> > callback, int maxMessages, IPerformanceCounterManager counters, object state) : base(identity, eventKeys, callback, maxMessages, counters, state) { if (streams == null) { throw new ArgumentNullException("streams"); } _streams = streams; List <Cursor> cursors = null; if (String.IsNullOrEmpty(cursor)) { cursors = new List <Cursor>(); } else { cursors = Cursor.GetCursors(cursor, _scaleoutCursorPrefix); // If the cursor had a default prefix, "d-", cursors might be null if (cursors == null) { cursors = new List <Cursor>(); } // If the streams don't match the cursors then throw it out else if (cursors.Count != _streams.Count) { cursors.Clear(); } } // No cursors so we need to populate them from the list of streams if (cursors.Count == 0) { for (int streamIndex = 0; streamIndex < _streams.Count; streamIndex++) { AddCursorForStream(streamIndex, cursors); } } _cursors = cursors; }
public DefaultSubscription(string identity, IList <string> eventKeys, TopicLookup topics, string cursor, Func <MessageResult, object, Task <bool> > callback, int maxMessages, IStringMinifier stringMinifier, IPerformanceCounterManager counters, object state) : base(identity, eventKeys, callback, maxMessages, counters, state) { _stringMinifier = stringMinifier; if (String.IsNullOrEmpty(cursor)) { _cursors = GetCursorsFromEventKeys(EventKeys, topics); } else { // Ensure delegate continues to use the C# Compiler static delegate caching optimization. _cursors = Cursor.GetCursors(cursor, _defaultCursorPrefix, (k, s) => UnminifyCursor(k, s), stringMinifier) ?? GetCursorsFromEventKeys(EventKeys, topics); } _cursorTopics = new List <Topic>(); if (!String.IsNullOrEmpty(cursor)) { // Update all of the cursors so we're within the range for (int i = _cursors.Count - 1; i >= 0; i--) { Cursor c = _cursors[i]; Topic topic; if (!EventKeys.Contains(c.Key)) { _cursors.Remove(c); } else if (!topics.TryGetValue(_cursors[i].Key, out topic) || _cursors[i].Id > topic.Store.GetMessageCount()) { UpdateCursor(c.Key, 0); } } } // Add dummy entries so they can be filled in for (int i = 0; i < _cursors.Count; i++) { _cursorTopics.Add(null); } }