Пример #1
0
        public async Task ReceiveAsync(IContext context)
        {
            switch (context.Message)
            {
            case Started _:
                Console.Out.WriteLine("Started: " + context.Self.Id);

                Actor.EventStream.Subscribe <ClusterTopologyEvent>(clusterTopologyEvent =>
                {
                    Console.Out.WriteLine("Got inner ClusterTopologyEvent");
                    context.Self.Tell(clusterTopologyEvent);
                });
                break;

            case PID brokerPid:
                _brokers.Add(brokerPid);
                context.Watch(brokerPid);
                break;

            case Terminated terminated:
                _brokers.Remove(terminated.Who);
                context.Unwatch(terminated.Who);
                break;

            case ClusterTopologyEvent clusterTopologyEvent:
                Console.Out.WriteLine("clusterTopologyEvent");
                _brokers.Clear();
                foreach (MemberStatus memberStatus in clusterTopologyEvent.Statuses)
                {
                    if (memberStatus.Alive)
                    {
                        PID remoteBrokerActorPid = new PID(memberStatus.Address, context.Self.Id);
                        GetPublisherPiDsResponse getPublisherPiDsResponse = await remoteBrokerActorPid
                                                                            .RequestAsync <GetPublisherPiDsResponse>(new GetPublisherPiDs())
                                                                            .ConfigureAwait(false);
                    }
                }

                break;
            }
        }
Пример #2
0
 public ProcessNameExistException(string name, PID pid) : base($"a Process with the name '{name}' already exists")
 {
     Name = name;
     Pid  = pid;
 }
Пример #3
0
 public Task <T> RequestAsync <T>(PID target, object message)
 => RequestAsync(target, message, new FutureProcess <T>());
Пример #4
0
 public Task <T> RequestAsync <T>(PID target, object message, TimeSpan timeout)
 => RequestAsync(target, message, new FutureProcess <T>(timeout));
Пример #5
0
 public void Send(PID target, object message) => SendUserMessage(target, message);
 public void Remove(PID pid)
 {
     _localActorRefs.Remove(pid.Id);
 }
Пример #7
0
 public Failure(PID who, Exception reason, RestartStatistics crs)
 {
     Who               = who;
     Reason            = reason;
     RestartStatistics = crs;
 }
Пример #8
0
 public virtual Task <T> RequestAsync <T>(PID target, object message) => _context.RequestAsync <T>(target, message);
 public virtual void Watch(PID pid) => _context.Watch(pid);
Пример #10
0
 public Task <T> RequestAsync <T>(PID target, object message)
 {
     throw new NotImplementedException();
 }
Пример #11
0
 public Task <T> RequestAsync <T>(PID target, object message, CancellationToken cancellationToken)
 {
     throw new NotImplementedException();
 }
Пример #12
0
        public void Request(PID target, object message, PID sender)
        {
            var envelope = new MessageEnvelope(message, sender, null);

            Tell(target, envelope);
        }
Пример #13
0
 private Task DefaultSender(ISenderContext context, PID target, MessageEnvelope message)
 {
     target.Tell(message);
     return(Actor.Done);
 }
Пример #14
0
 protected internal override void SendUserMessage(PID pid, object message)
 {
     throw new InvalidOperationException($"Guardian actor cannot receive any user messages.");
 }
Пример #15
0
 public void EscalateFailure(Exception reason, PID who)
 {
     throw new InvalidOperationException("Guardian cannot escalate failure.");
 }
Пример #16
0
 public virtual Task <T> RequestAsync <T>(PID target, object message, TimeSpan timeout) =>
 _context.RequestAsync <T>(target, message, timeout);
Пример #17
0
 public virtual Task <T> RequestAsync <T>(PID target, object message, CancellationToken cancellationToken) =>
 _context.RequestAsync <T>(target, message, cancellationToken);
 public virtual void Unwatch(PID pid) => _context.Unwatch(pid);
Пример #19
0
 public MessageSender(object message, PID sender)
 {
     Message = message;
     Sender  = sender;
 }
 public virtual void Forward(PID target) => _context.Forward(target);
Пример #21
0
 public Unwatch(PID watcher)
 {
     Watcher = watcher;
 }
Пример #22
0
 protected internal abstract void SendUserMessage(PID pid, object message);
Пример #23
0
 public void Unwatch(PID pid) => pid.SendSystemMessage(new Unwatch(Self));
Пример #24
0
 public virtual void Stop(PID pid)
 {
     SendSystemMessage(pid, Proto.Stop.Instance);
 }
Пример #25
0
        public void Request(PID target, object message)
        {
            var messageEnvelope = new MessageEnvelope(message, Self, null);

            SendUserMessage(target, messageEnvelope);
        }
Пример #26
0
 protected internal abstract void SendSystemMessage(PID pid, object message);
Пример #27
0
 public Task <T> RequestAsync <T>(PID target, object message, CancellationToken cancellationToken)
 => RequestAsync(target, message, new FutureProcess <T>(cancellationToken));
Пример #28
0
 public virtual void Send(PID target, object message) => _context.Send(target, message);
Пример #29
0
 public void AddChild(PID pid) => Children = Children.Add(pid);
Пример #30
0
 public virtual void Request(PID target, object message) => _context.Request(target, message);