Skip to Content
Mastering Functional Programming
book

Mastering Functional Programming

by Anatolii Kmetiuk
August 2018
Intermediate to advanced
380 pages
10h 2m
English
Packt Publishing
Content preview from Mastering Functional Programming

Implementation

Let's start by defining the Greeter actor, as it is the simpler one:

class Greeter extends Actor {  val log = Logging(context.system, this)  def receive = {    case SayHello(name) => log.info(s"Greetings to $name")    case Die =>      context stop self      sender ! Dead  }}

The actor is going to accept a say hello message that is parameterized by the name the actor is supposed to greet. On receiving this message, it is going to perform a log output.

The Greeter actor has the means for the other actors to stop it. We have already discussed that one of the requirements of the task is that the manager actor should be able to terminate its existing actress to spawn a new actor. This can be accomplished by sending a message to this Greeter actor. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Functional Programming

Learning Functional Programming

Jack Widman

Publisher Resources

ISBN: 9781788620796Supplemental Content