示例#1
0
 private void OnDisposed(JournalSubscription subscription)
 {
     lock (_subscriptions)
     {
         _subscriptions.Remove(subscription.Id);
     }
 }
 private void RemoveSubscription(JournalSubscription subscription)
 {
     lock (_journal)
     {
         _subscriptions.Remove(subscription.Id);
     }
 }
示例#3
0
        public IJournalSubscription Subscribe(long @from, Action <JournalRecord> handler)
        {
            var sub = new JournalSubscription(handler, @from, OnDisposed);

            lock (_subscriptions)
            {
                _subscriptions.Add(sub.Id, sub);
            }

            return(sub);
        }
        public IJournalSubscription Subscribe(long from, Action<JournalRecord> handler)
        {
            if (from != _journalWriter.NextRecord)
            {
                throw new NotSupportedException("CatchupSubscriptions are not supported by this FileStorageProvider");
            }

            var sub = new JournalSubscription(handler, from, OnDisposed);
            lock (_subscriptions)
            {
                _subscriptions.Add(sub.Id, sub);
            }

            return sub;
        }
        public IJournalSubscription Subscribe(long from, Action <JournalRecord> handler)
        {
            var subscription = new JournalSubscription(handler, from, RemoveSubscription);

            lock (_journal)
            {
                _subscriptions.Add(subscription.Id, subscription);
                for (var i = (int)from; i < _journal.Count; i++)
                {
                    subscription.Handle(_journal[i]);
                }
            }

            return(subscription);
        }