public ScaleoutSubscription(string identity, IEnumerable <string> eventKeys, string cursor, ConcurrentDictionary <string, Linktionary <ulong, ScaleoutMapping> > streamMappings, Func <MessageResult, Task <bool> > callback, int maxMessages, IPerformanceCounterManager counters) : base(identity, eventKeys, callback, maxMessages, counters) { if (streamMappings == null) { throw new ArgumentNullException("streamMappings"); } _streams = streamMappings; IEnumerable <Cursor> cursors = null; if (cursor == null) { cursors = from key in _streams.Keys select new Cursor(key, GetCursorId(key)); } else { cursors = Cursor.GetCursors(cursor); } _cursors = new List <Cursor>(cursors); }
public DefaultSubscription(string identity, IEnumerable <string> eventKeys, IDictionary <string, Topic> topics, string cursor, Func <MessageResult, Task <bool> > callback, int maxMessages, IPerformanceCounterManager counters) : base(identity, eventKeys, callback, maxMessages, counters) { IEnumerable <Cursor> cursors = null; if (cursor == null) { cursors = from key in eventKeys select new Cursor { Key = key, Id = GetMessageId(topics, key) }; } else { cursors = Cursor.GetCursors(cursor); } _cursors = new List <Cursor>(cursors); _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); } }