Example #1
0
 public virtual bool AddEvent(string key, Topic topic)
 {
     lock (EventKeys)
     {
         return EventKeys.Add(key);
     }
 }
Example #2
0
        public override bool AddEvent(string eventKey, Topic topic)
        {
            lock (_lockObj)
            {
                // O(n), but small n and it's not common
                var index = _cursors.FindIndex(c => c.Key == eventKey);
                if (index == -1)
                {
                    _cursors.Add(new Cursor
                    {
                        Key = eventKey,
                        Id = GetMessageId(topic)
                    });

                    _cursorTopics.Add(topic);

                    return true;
                }

                return false;
            }
        }
 public override void SetEventTopic(string key, Topic topic)
 {
     // This isn't relevant to us as EventKeys is up to date
 }
 public override bool AddEvent(string key, Topic topic)
 {
     // This isn't relevant to us as EventKeys is up to date
     return false;
 }
Example #5
0
 public void SetCursorTopic(string key, Topic topic)
 {
     lock (_lockObj)
     {
         // O(n), but small n and it's not common
         var index = _cursors.FindIndex(c => c.Key == key);
         if (index != -1)
         {
             _cursors[index].Topic = topic;
         }
     }
 }
Example #6
0
 public void AddOrUpdateCursor(string key, ulong id, Topic topic)
 {
     lock (_lockObj)
     {
         // O(n), but small n and it's not common
         var index = _cursors.FindIndex(c => c.Key == key);
         if (index == -1)
         {
             _cursors.Add(new Cursor
             {
                 Key = key,
                 Id = id,
                 Topic = topic
             });
         }
     }
 }
Example #7
0
        private ulong GetMessageId(Topic topic)
        {
            if (topic == null)
            {
                return 0;
            }

            return topic.Store.GetMessageCount();
        }
Example #8
0
 public override void SetEventTopic(string eventKey, Topic topic)
 {
     lock (_lockObj)
     {
         // O(n), but small n and it's not common
         var index = _cursors.FindIndex(c => c.Key == eventKey);
         if (index != -1)
         {
             _cursorTopics[index] = topic;
         }
     }
 }
Example #9
0
 public abstract bool AddEvent(string key, Topic topic);
Example #10
0
 public abstract void SetEventTopic(string key, Topic topic);
Example #11
0
        private void ScheduleTopic(Topic topic)
        {
            try
            {
                topic.SubscriptionLock.EnterReadLock();

                for (int i = 0; i < topic.Subscriptions.Count; i++)
                {
                    ISubscription subscription = topic.Subscriptions[i];
                    _broker.Schedule(subscription);
                }
            }
            finally
            {
                topic.SubscriptionLock.ExitReadLock();
            }
        }
Example #12
0
 public virtual void SetEventTopic(string key, Topic topic)
 {
     lock (EventKeys)
     {
         EventKeys.Add(key);
     }
 }
Example #13
0
 public virtual bool AddEvent(string key, Topic topic)
 {
     return false;
 }
Example #14
0
 public virtual void SetEventTopic(string key, Topic topic)
 {
 }