Unit Tell(object message, ProcessId sender, string inbox, Message.Type type, Message.TagSpec tag)
        {
            var dto = RemoteMessageDTO.Create(message, ProcessId, sender, type, tag);
            // The standard structure for remote js relay paths are  "/root/js/{connection-id}/..."
            var connectionId = ProcessId.Skip(2).Take(1).Name.Value;

            dto.To = ProcessId.Skip(3).Path;
            var relayMsg = new OutboundRelayMsg(connectionId, dto, dto.To, sender, dto.RequestId != -1);

            return(Process.tell(RelayId, relayMsg, sender));
        }
 public Unit Tell(object message, ProcessId sender, Message.TagSpec tag) =>
 IterRoleMembers(d => d.Tell(message, sender, tag));
Пример #3
0
 internal static RemoteMessageDTO CreateMessage(object message, ProcessId to, ProcessId sender, Message.Type type, Message.TagSpec tag) =>
 new RemoteMessageDTO
 {
     Type        = (int)type,
     Tag         = (int)tag,
     To          = to.Path,
     RequestId   = -1,
     MessageId   = Guid.NewGuid(),
     Sender      = sender.ToString(),
     ReplyTo     = sender.ToString(),
     ContentType = message == null
                         ? null
                         : message.GetType().AssemblyQualifiedName,
     Content = message == null
                         ? null
                         : JsonConvert.SerializeObject(message, ActorSystemConfig.Default.JsonSerializerSettings)
 };
Пример #4
0
 internal static RemoteMessageDTO Create(object message, ProcessId to, ProcessId sender, Message.Type type, Message.TagSpec tag) =>
 map(message as ActorRequest, req =>
     req == null
             ? map(message as ActorResponse, res =>
                   res == null
                     ? CreateMessage(message, to, sender, type, tag)
                     : CreateResponse(res, to, sender))
             : CreateRequest(req, to, sender));
Пример #5
0
        Unit TellNoIO(object message, ProcessId sender, string inbox, Message.Type type, Message.TagSpec tag)
        {
            ValidateMessageType(message, sender);
            var dto            = RemoteMessageDTO.Create(message, ProcessId, sender, type, tag);
            var inboxKey       = ActorInboxCommon.ClusterInboxKey(ProcessId, inbox);
            var inboxNotifyKey = ActorInboxCommon.ClusterInboxNotifyKey(ProcessId, inbox);

            Cluster.Enqueue(inboxKey, dto);
            var clientsReached = Cluster.PublishToChannel(inboxNotifyKey, dto.MessageId);

            return(unit);
        }
Пример #6
0
 public Unit Tell(object message, ProcessId sender, string inbox, Message.Type type, Message.TagSpec tag) =>
 ProcessOp.IO(() => TellNoIO(message, sender, inbox, type, tag));
Пример #7
0
        public Unit Tell(object message, Schedule schedule, ProcessId sender, Message.TagSpec tag)
        {
            var sessionId = ActorContext.SessionId;

            return(LocalScheduler.Push(schedule, Actor.Id, m => Inbox.Tell(Inbox.ValidateMessageType(m, sender), sender, sessionId), message));
        }
 public Unit Tell(object message, ProcessId sender, Message.TagSpec tag) =>
 Tell(message, sender, "user", Message.Type.User, tag);
Пример #9
0
 internal static RemoteMessageDTO Create(object message, ProcessId to, ProcessId sender, Message.Type type, Message.TagSpec tag, Option <SessionId> sessionId, long due) =>
 map(message as ActorRequest, req =>
     req == null
             ? map(message as ActorResponse, res =>
                   res == null
                     ? CreateMessage(message, to, sender, type, tag, sessionId, due)
                     : CreateResponse(res, to, sender, sessionId))
             : CreateRequest(req, to, sender, sessionId));
Пример #10
0
 public Unit Tell(object message, Schedule schedule, ProcessId sender, Message.TagSpec tag) =>
 LocalScheduler.Push(schedule, ProcessId, m => Tell(m, sender, "tell", Message.Type.User), message);
Пример #11
0
        Unit DoScheduleNoIO(object message, ProcessId sender, Schedule schedule, Message.Type type, Message.TagSpec tag)
        {
            var inboxKey = ActorInboxCommon.ClusterScheduleKey(ProcessId);
            var id       = schedule.Key ?? Guid.NewGuid().ToString();
            var current  = Cluster.GetHashField <RemoteMessageDTO>(inboxKey, id);

            message = current.Match(
                Some: last =>
            {
                var a = MessageSerialiser.DeserialiseMsg(last, ProcessId) as UserMessage;
                var m = a == null
                        ? message
                        : schedule.Fold(a.Content, message);
                return(m);
            },
                None: () => schedule.Fold(schedule.Zero, message));

            ValidateMessageType(message, sender);

            var dto = RemoteMessageDTO.Create(message, ProcessId, sender, type, tag, SessionId, schedule.Due.Ticks);

            tell(ProcessId.Take(1).Child("system").Child("scheduler"), Scheduler.Msg.AddToSchedule(inboxKey, id, dto));

            //Cluster.HashFieldAddOrUpdate(inboxKey, id, dto);
            return(unit);
        }
Пример #12
0
 Unit DoSchedule(object message, Schedule schedule, ProcessId sender, Message.Type type, Message.TagSpec tag) =>
 transactionalIO
         ? DoScheduleNoIO(message, sender, schedule, type, tag)
         : ProcessOp.IO(() => DoScheduleNoIO(message, sender, schedule, type, tag));
Пример #13
0
 public Unit Tell(object message, Schedule schedule, ProcessId sender, string inbox, Message.Type type, Message.TagSpec tag) =>
 schedule == Schedule.Immediate
         ? transactionalIO
             ? TellNoIO(message, sender, inbox, type, tag)
             : ProcessOp.IO(() => TellNoIO(message, sender, inbox, type, tag))
         : schedule.Type == Schedule.PersistenceType.Ephemeral
             ? LocalScheduler.Push(schedule, ProcessId, m => TellNoIO(m, sender, inbox, type, tag), message)
             : DoSchedule(message, schedule, sender, type, tag);
Пример #14
0
 public Unit Tell(object message, Schedule schedule, ProcessId sender, Message.TagSpec tag) =>
 LocalScheduler.Push(schedule, Actor.Id, m => Inbox.Tell(Inbox.ValidateMessageType(m, sender), sender), message);
 public TellMessage(ProcessId processId, object message, ProcessId sender, TagSpec tag)
 {
     ProcessId = processId;
     Message = message;
     Sender = sender;
     this.tag = tag;
 }
 public Unit Tell(object message, ProcessId sender, Message.TagSpec tag) =>
 Raise <Unit>(sender);
Пример #17
0
 public Unit Tell(object message, ProcessId sender, Message.TagSpec tag) =>
 ProcessOp.IO(() =>
 {
     message = Inbox.ValidateMessageType(message, sender);
     return(Inbox.Tell(message, sender));
 });
Пример #18
0
 internal static RemoteMessageDTO CreateMessage(object message, ProcessId to, ProcessId sender, Message.Type type, Message.TagSpec tag, Option <SessionId> sessionId, long due) =>
 new RemoteMessageDTO
 {
     Type        = (int)type,
     Tag         = (int)tag,
     To          = to.ToString(),
     RequestId   = -1,
     MessageId   = Guid.NewGuid(),
     Sender      = sender.ToString(),
     ReplyTo     = sender.ToString(),
     ContentType = message?.GetType()?.AssemblyQualifiedName,
     Content     = message == null
                         ? null
                         : JsonConvert.SerializeObject(message, ActorSystemConfig.Default.JsonSerializerSettings),
     SessionId = sessionId.Map(s => s.Value).IfNoneUnsafe(() => null),
     Due       = due
 };
Пример #19
0
 public Unit Tell(object message, ProcessId sender, Message.TagSpec tag) =>
 transactionalIO
         ? Inbox.Tell(Inbox.ValidateMessageType(message, sender), sender)
         : ProcessOp.IO(() => Inbox.Tell(Inbox.ValidateMessageType(message, sender), sender));
Пример #20
0
 public Unit Tell(object message, ProcessId sender, Message.TagSpec tag) =>
 Inbox.Tell(message, sender);