Registry

Name-based actor discovery and lookup.

Overview

The Registry provides a way to register actors by name and look them up later. This is useful when actors need to communicate without having direct address references.

1
2
3
4
5
6
7
8
9

Registering Actors

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

Looking Up Actors

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Registry::get() returns None if no actor is registered with that name, or if the registered actor has stopped.

Automatic Cleanup

When a registered actor stops, it is automatically removed from the registry:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Service Discovery Pattern

services.rs
rust
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

Best Practices

Use constants for names

Define registry names as constants to avoid typos and enable refactoring.

Register early

Register services during startup before other actors try to look them up.

Handle missing services gracefully

Always check if get() returns None and handle the case appropriately.

One actor per name

Each name should map to exactly one actor. Re-registering overwrites the previous entry.

Next Steps