A manager actor coordinates distributed work: it receives a collection of tasks, splits the work, creates or selects worker actors, delegates each piece, and tracks completion. In the text-parsing example, a guardian sends text to the manager, which creates one worker per text and sends each worker a parsing request. section 3.1 section 3.0
A manager actor typically performs these steps:
- Receives a delegation message containing the work, such as a list of texts. section 3.1.1
- Creates a worker for each task and sends the worker a command to process it. section 3.2.2
- Adapts worker responses into messages that belong to the manager’s protocol. section 3.1.3
- Receives success or failure reports and records the completed task. section 3.2.2
The manager belongs to an actor hierarchy. A guardian creates it with context.spawn and sends it a Delegate message using tell (!). The manager then creates workers beneath itself, preserving the parent-child structure that makes delegation straightforward. section 3.1.2 section 3.0
Worker replies require an adapter because each actor understands its own protocol. The manager declares an adapter message and an adapter function, translating the worker’s response before handling it as a manager report. section 3.1.3
Parsing two texts
A guardian starts the manager with “-one-” and “--two--”. The manager sends each text to a separate worker. Runtime output shows both workers producing “one” and “two”, followed by manager messages confirming that both texts finished. section 3.1.1 section 3.1.2
Use the message-flow diagram to follow delegation from the manager to workers and completion notifications back to the manager. section 3.1
