Exemplo n.º 1
0
        protected override void OnReceive(object message)
        {
            switch (message)
            {
            case InSyncCommand insync:
                coordinatorInsync = true;
                userCoordinatorHelper.SetInSync(true);
                break;

            case IEvent @event:
                userCoordinatorHelper.OnEvent(Sender, @event);
                break;

            case ICommand command:
                userCoordinatorHelper.OnCommand(Sender, command, persist);
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor for streaming usercoordinator
        /// </summary>
        /// <param name="startAsInSync"></param>
        /// <param name="coordinatorPerist"></param>
        /// <param name="childPersist">Important to store objects of type IUserEvent<TKey>, coordinator needs to send events to correct userActor</param>
        public UserCoordinator(
            bool startAsInSync,
            Action <IEvent, Action <IEvent> > coordinatorPerist,
            Action <TKey, IEvent, Action <IEvent> > childPersist)
        {
            coordinatorInsync = startAsInSync;
            this.persist      = coordinatorPerist;
            this.childPersist = childPersist;

            var ctx = Context;

            userCoordinatorHelper = new UserCoordinatorHelper <TKey, TUser>(CreateChildActor, () => ctx);

            if (startAsInSync)
            {
                userCoordinatorHelper.SetInSync();
            }
        }
 protected override void OnReplaySuccess()
 {
     base.OnReplaySuccess();
     userCoordinatorHelper.SetInSync(false);
 }