petabridge / akka-bootcamp

Self-paced training course to learn Akka.NET fundamentals from scratch
http://learnakka.net/
Apache License 2.0
1.04k stars 1.57k forks source link

Lesson 1.5 does not provide option to submit exit command. #320

Open woodpk opened 3 years ago

woodpk commented 3 years ago

With the changes in the console reader actor in lesson 5 unit 1, it seems the exit behavior has been removed. Is this intentional or accidental ? The console no longer reads / allows input after providing the file path and hitting enter.

pyongary commented 1 year ago

It looks like the FileValidatorActor should be changed to

        protected override void OnReceive(object message)
        {
            var msg = message as string;
            if (string.IsNullOrEmpty(msg))
            {
                _consoleWriterActor.Tell(new Messages.NullInputError("Input was blank. Please try again.\n"));

                Sender.Tell(new Messages.ContinueProcessing());
            }
            else
            {
                var vaild = isFileUri(msg);
                if (vaild)
                {
                    _consoleWriterActor.Tell(new Messages.InputSuccess($"Starting processing for {msg}"));
                    Context.ActorSelection("akka://MyActorSystem/user/tailCoordinatorActor").Tell(new TailCoordinatorActor.StartTail(msg, _consoleWriterActor));
                    // _tailCoordinatorActor.Tell(new TailCoordinatorActor.StartTail(msg, _consoleWriterActor));
                }
                else
                {
                    _consoleWriterActor.Tell(new Messages.ValidationError($"{msg} is not a existing URI on Disk.\n"));
                }
                Sender.Tell(new Messages.ContinueProcessing());
            }
        }