Skip to content

Commit fc6f1f8

Browse files
committed
Document ElasticManager
1 parent 7354980 commit fc6f1f8

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

src/elastic.jl

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,35 @@ else
1111
my_errormonitor(t) = nothing
1212
end
1313

14+
"""
15+
ElasticManager <: Distributed.ClusterManager
16+
17+
A cluster manager that allows for adding and removing workers dynamically.
18+
19+
Constructor:
20+
21+
```julia
22+
function ElasticManager(;
23+
addr=IPv4("127.0.0.1"), port=9009, cookie=nothing,
24+
topology=:all_to_all, manage_callback=elastic_no_op_callback, printing_kwargs=()
25+
)
26+
```
27+
28+
The manager will listen for worker connections on `addr:port`. Workers have
29+
to authenticate themselves with `cookie` (randomly generated by default).
30+
31+
If `manage_callback` is set to a user-provided `my_manage_callback`, it will
32+
be called on the primary Julia process when `Distributed.manage` adds or
33+
removes an elastic worker. The callback signature is
34+
35+
```julia
36+
my_manage_callback(mgr::ElasticManager, id::Integer, :register)
37+
my_manage_callback(mgr::ElasticManager, id::Integer, :deregister)
38+
```
39+
40+
This can be used to automatically add workers to a `Distributed.WorkerPool`,
41+
and so on.
42+
"""
1443
struct ElasticManager <: Distributed.ClusterManager
1544
active::Dict{Int, Distributed.WorkerConfig} # active workers
1645
pending::Channel{Sockets.TCPSocket} # to be added workers
@@ -57,9 +86,9 @@ struct ElasticManager <: Distributed.ClusterManager
5786
end
5887
end
5988

60-
ElasticManager(port) = ElasticManager(;port=port)
61-
ElasticManager(addr, port) = ElasticManager(;addr=addr, port=port)
62-
ElasticManager(addr, port, cookie) = ElasticManager(;addr=addr, port=port, cookie=cookie)
89+
@deprecate ElasticManager(port) ElasticManager(;port=port)
90+
@deprecate ElasticManager(addr, port) ElasticManager(;addr=addr, port=port)
91+
@deprecate ElasticManager(addr, port, cookie) ElasticManager(;addr=addr, port=port, cookie=cookie)
6392

6493
elastic_no_op_callback(::ElasticManager, ::Integer, ::Symbol) = nothing
6594

0 commit comments

Comments
 (0)