public PeerEntry(PeerDescriptor descriptor, ConcurrentDictionary <MessageTypeId, PeerSubscriptionTree> globalSubscriptionsIndex) { Peer = new Peer(descriptor.Peer); TimestampUtc = descriptor.TimestampUtc ?? DateTime.UtcNow; _globalSubscriptionsIndex = globalSubscriptionsIndex; }
public PeerDescriptor(PeerDescriptor other) { Peer = new Peer(other.Peer); PeerId = Peer.Id; Subscriptions = other.Subscriptions?.ToArray() ?? Array.Empty <Subscription>(); TimestampUtc = other.TimestampUtc; }
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); }
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); }
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); }
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); }
public PeerSubscriptionsUpdated(PeerDescriptor peerDescriptor) { PeerDescriptor = peerDescriptor; }
public PeerStarted(PeerDescriptor peerDescriptor) { PeerDescriptor = peerDescriptor; }
public PeerActivated(PeerDescriptor peerDescriptor) { PeerDescriptor = peerDescriptor; }
public void AddOrUpdatePeerEntry(PeerDescriptor peerDescriptor) { _peerRepository.AddOrUpdatePeer(peerDescriptor); }
public PeerEntry(PeerDescriptor peerDescriptor) { PeerDescriptor = new PeerDescriptor(peerDescriptor); DynamicSubscriptions = new List <Subscription>(); }