Example #1
0
        public StorageActor(IPecanLogger logger)
        {
            this.Logger = logger;
            logger?.Trace(this.GetType().Name, $"{this.GetType().Name} Creating {nameof(StorageReadActor)} .. ");
            //multi reader
            IActorRef actorReadPool = Context.ActorOf(Props.Create(() => new StorageReadActor(logger)).WithRouter(new RoundRobinPool(1000)), TypeOfWrapper.TypeOf(typeof(StorageReadActor)).Name);

            logger?.Trace(this.GetType().Name, $"{this.GetType().Name} Creating {nameof(StorageWriteActor)} .. ");
            //single writer
            IActorRef actorWriteRef = Context.ActorOf(Props.Create(() => new StorageWriteActor(logger)), TypeOfWrapper.TypeOf(typeof(StorageWriteActor)).Name);

            this.Receive <Func <bool> >(
                message =>
            {
                logger?.Trace(this.GetType().Name, $"{this.GetType().Name} forwarding message {message?.GetType().Name} to {actorWriteRef.Path.ToStringWithAddress()}");
                actorWriteRef.Forward(message);
            });
            this.Receive <Func <object> >(
                message =>
            {
                logger?.Trace(this.GetType().Name, $"{this.GetType().Name} forwarding message {message?.GetType().Name} to {actorReadPool.Path.ToStringWithAddress()}");

                actorReadPool.Forward(message);
            });
            this.Receive <Terminated>(
                t =>
            {
                string message = "Actor just got terminated : " + t.ActorRef.Path;
                logger?.Fatal(this.GetType().Name, message);
            });
        }
Example #2
0
 public StorageReadActor(IPecanLogger logger)
 {
     this.Receive <Func <object> >(
         message =>
     {
         if (message == null)
         {
             logger?.Fatal(this.GetType().Name, $"Error null{this.GetType().Name} message {message?.GetType().Name}");
         }
         else
         {
             logger?.Trace(this.GetType().Name, $"{this.GetType().Name} Executing message {message?.GetType().Name}");
             this.Sender.Tell(message());
         }
     });
 }