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

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

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