コード例 #1
0
 public ActorProcessConfiguration(ActorId id, Func <IActor> actorFactory, ICanPost parent, ActorType type)
 {
     Id           = id;
     ActorFactory = actorFactory;
     Parent       = parent;
     Type         = type;
 }
コード例 #2
0
        public IActorProcess Add(Func <IActor> actorFactory, string adress, ICanPost parent)
        {
            var id            = NextId(adress, ActorType.Remote);
            var configuration = new ActorProcessConfiguration(id, actorFactory, parent, id.Type, new Uri(adress));

            return(AddInternal <IRemoteActorProcess>(configuration));
        }
コード例 #3
0
        public IActorProcess Add(Func <IActor> actorFactory, ICanPost parent)
        {
            var id            = NextId(null, ActorType.Transient);
            var configuration = new ActorProcessConfiguration(id, actorFactory, parent, id.Type);

            return(AddInternal <IActorProcess>(configuration));
        }
コード例 #4
0
 public MessageContext(IActorProcess actor, IEvent message, ICanPost sender, IActorRegistry actorRegistry)
 {
     Actor    = actor;
     Message  = message;
     Sender   = sender;
     Registry = actorRegistry;
 }
コード例 #5
0
 private void EnsureCanSend(ICanPost target)
 {
     if (target.Id.Type == ActorType.Remote && _actorProcess.Id.Type == ActorType.Transient)
     {
         throw new Exception("cannot send from transient to remote");
     }
 }
コード例 #6
0
        public IActorProcess Add(Func <IActor> actorFactory, string adress, ICanPost parent, string name)
        {
            var process = _registry.Add(actorFactory, adress, parent, name);

            _directory.Register(new ClusterMember(process.Id));

            return(process);
        }
コード例 #7
0
        public RemoteWriterService(ICanPost remote, ISerializer serializer)
        {
            var uri = new Uri(remote.Id.Adress);

            _channel    = new Channel($"{uri.Host}:{uri.Port}", ChannelCredentials.Insecure);
            _client     = new Transport.TransportClient(_channel);
            _serializer = serializer;
        }
コード例 #8
0
 private MessageEnvelope Serialize(IEvent message, ICanPost sender)
 {
     return(new MessageEnvelope()
     {
         MessageData = ByteString.FromStream(new MemoryStream(_serializer.Serialize(message))),
         MessageType = message.GetType().ToString(),
         Sender = sender?.Id.ToPid()
     });
 }
コード例 #9
0
        public IActorProcess Add(Func <IActor> actorFactory, string adress, ICanPost parent, string name)
        {
            if (_actors.ContainsKey(name))
            {
                throw new Exception("already exist");
            }

            var id            = NextId(name, adress, ActorType.Remote);
            var configuration = new ActorProcessConfiguration(id, actorFactory, parent, id.Type);

            return(AddInternal <IActorProcess>(configuration));
        }
コード例 #10
0
        public void Post(IEvent msg, ICanPost sender)
        {
            var context = new MessageContext(_process, msg, sender, _registry);

            _messages.Add(context);
        }
コード例 #11
0
 public void Post(IEvent msg, ICanPost sender)
 {
     _mailbox.Post(msg, sender);
 }
コード例 #12
0
 public IActorProcess Add(Func <IActor> actorFactory, ICanPost parent)
 {
     return(_registry.Add(actorFactory, parent));
 }
コード例 #13
0
 public void Write(ICommand message, ICanPost sender, TimeSpan timeout)
 {
     _client.Send(Serialize(message, sender), deadline: DateTime.Now.Add(timeout));
 }
コード例 #14
0
 public void Write(ICommand message, ICanPost sender, CancellationToken cancellationToken)
 {
     _client.Send(Serialize(message, sender), cancellationToken: cancellationToken);
 }
コード例 #15
0
 public void Write(IEvent message, ICanPost sender)
 {
     _client.Send(Serialize(message, sender));
 }
コード例 #16
0
 public void Post(IEvent msg, ICanPost sender)
 {
     _writer.Write(msg, sender);
 }