コード例 #1
0
ファイル: PeerEntry.cs プロジェクト: thomasraynal/busy
        public PeerEntry(PeerDescriptor descriptor, ConcurrentDictionary <MessageTypeId, PeerSubscriptionTree> globalSubscriptionsIndex)
        {
            Peer         = new Peer(descriptor.Peer);
            TimestampUtc = descriptor.TimestampUtc ?? DateTime.UtcNow;

            _globalSubscriptionsIndex = globalSubscriptionsIndex;
        }
コード例 #2
0
 public PeerDescriptor(PeerDescriptor other)
 {
     Peer          = new Peer(other.Peer);
     PeerId        = Peer.Id;
     Subscriptions = other.Subscriptions?.ToArray() ?? Array.Empty <Subscription>();
     TimestampUtc  = other.TimestampUtc;
 }
コード例 #3
0
        private void CreateDirectoryPeer(string endPoint)
        {
            var peerId = new PeerId("Abc.Zebus.DirectoryService");
            var peer   = new Peer(peerId, endPoint);

            var selfDescriptor = new PeerDescriptor(peer.Id, peer.EndPoint, peer.IsUp, peer.IsResponding, DateTime.Now, _bus.AutoSubscribes.ToArray());

            AddOrUpdatePeerEntry(selfDescriptor);
        }
コード例 #4
0
        public Task RegisterAsync(Peer self, IEnumerable <Subscription> subscriptions)
        {
            _self = self;

            var selfDescriptor = new PeerDescriptor(self.Id, self.EndPoint, self.IsUp, self.IsResponding, DateTime.Now, subscriptions.ToArray());

            AddOrUpdatePeerEntry(selfDescriptor);

            _bus.Publish(new PeerActivated(selfDescriptor));

            return(Task.CompletedTask);
        }
コード例 #5
0
        public void AddOrUpdatePeer(PeerDescriptor peerDescriptor)
        {
            if (_peers.ContainsKey(peerDescriptor.PeerId))
            {
                return;
            }

            _logger.LogInformation($"Register {peerDescriptor}");

            var newPeerEntry = new PeerEntry(peerDescriptor);

            _peers.AddOrUpdate(peerDescriptor.PeerId, newPeerEntry, (peerId, existingPeerEntry) => peerDescriptor.TimestampUtc >= existingPeerEntry.PeerDescriptor.TimestampUtc ? newPeerEntry : existingPeerEntry);
        }
コード例 #6
0
        public void AddOrUpdatePeerEntry(PeerDescriptor peerDescriptor)
        {
            var subscriptions = peerDescriptor.Subscriptions ?? Array.Empty <Subscription>();

            _logger.LogInformation($"Register {peerDescriptor}");

            var peerEntry = _peers.AddOrUpdate(peerDescriptor.PeerId,
                                               key => new PeerEntry(peerDescriptor, _globalSubscriptionsIndex),
                                               (key, entry) =>
            {
                entry.Peer.EndPoint     = peerDescriptor.Peer.EndPoint;
                entry.Peer.IsUp         = peerDescriptor.Peer.IsUp;
                entry.Peer.IsResponding = peerDescriptor.Peer.IsResponding;
                entry.TimestampUtc      = peerDescriptor.TimestampUtc ?? DateTime.UtcNow;

                return(entry);
            });

            peerEntry.SetSubscriptions(subscriptions, peerDescriptor.TimestampUtc);
        }
コード例 #7
0
 public PeerSubscriptionsUpdated(PeerDescriptor peerDescriptor)
 {
     PeerDescriptor = peerDescriptor;
 }
コード例 #8
0
 public PeerStarted(PeerDescriptor peerDescriptor)
 {
     PeerDescriptor = peerDescriptor;
 }
コード例 #9
0
ファイル: PeerActivated.cs プロジェクト: thomasraynal/busy
 public PeerActivated(PeerDescriptor peerDescriptor)
 {
     PeerDescriptor = peerDescriptor;
 }
コード例 #10
0
 public void AddOrUpdatePeerEntry(PeerDescriptor peerDescriptor)
 {
     _peerRepository.AddOrUpdatePeer(peerDescriptor);
 }
コード例 #11
0
 public PeerEntry(PeerDescriptor peerDescriptor)
 {
     PeerDescriptor       = new PeerDescriptor(peerDescriptor);
     DynamicSubscriptions = new List <Subscription>();
 }