コード例 #1
0
ファイル: Prelude.cs プロジェクト: tanxeel90/echo-process
        /// <summary>
        /// Cancel an already scheduled message
        /// </summary>
        public static Unit cancelScheduled(ProcessId pid, string key)
        {
            var inboxKey = ActorInboxCommon.ClusterScheduleKey(pid);

            LocalScheduler.RemoveExistingScheduledMessage(pid, key);
            return(tell(pid.Take(1).Child("system").Child("scheduler"), Scheduler.Msg.RemoveFromSchedule(inboxKey, key)));
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: Prelude.cs プロジェクト: tanxeel90/echo-process
        /// <summary>
        /// Re-schedule an already scheduled message
        /// </summary>
        public static Unit reschedule(ProcessId pid, string key, DateTime when)
        {
            var inboxKey = ActorInboxCommon.ClusterScheduleKey(pid);

            LocalScheduler.Reschedule(pid, key, when);
            return(tell(pid.Take(1).Child("system").Child("scheduler"), Scheduler.Msg.Reschedule(inboxKey, key, when)));
        }
コード例 #4
0
        void SubscribeToScheduleInboxChannel()
        {
            cluster.UnsubscribeChannel(ActorInboxCommon.ClusterScheduleNotifyKey(actor.Id));
            cluster.SubscribeToChannel <string>(ActorInboxCommon.ClusterScheduleNotifyKey(actor.Id)).Subscribe(msg => scheduledItems++);
            // We want the check done asyncronously, in case the setup function creates child processes that
            // won't exist if we invoke directly.

            // TODO: Consider the implications of race condition here --- will probably need some large 'clear out' process that does a query
            //       on the cluster.  Or maybe this internal counter isn't the best approach.
            scheduledItems = cluster.GetHashFields(ActorInboxCommon.ClusterScheduleKey(actor.Id)).Count;
        }