MCPcopy Create free account
hub / github.com/actor-framework/actor-framework / client

Function client

examples/remoting/remote_spawn.cpp:151–172  ·  view source on GitHub ↗

--(rst-client-begin)--

Source from the content-addressed store, hash-verified

149
150// --(rst-client-begin)--
151void client(actor_system& sys, const config& cfg) {
152 auto host = get_or(cfg, "host", default_host);
153 auto port = get_or(cfg, "port", default_port);
154 auto node = sys.middleman().connect(host, port);
155 if (!node) {
156 sys.println("*** connect failed: {}", node.error());
157 return;
158 }
159 auto type = "calculator"; // type of the actor we wish to spawn
160 auto args = make_message(); // arguments to construct the actor
161 auto tout = std::chrono::seconds(30); // wait no longer than 30s
162 auto worker = sys.middleman().remote_spawn<calculator>(*node, type, args,
163 tout);
164 if (!worker) {
165 sys.println("*** remote spawn failed: {}", worker.error());
166 return;
167 }
168 // start using worker in main loop
169 client_repl(sys, *worker);
170 // be a good citizen and terminate remotely spawned actor before exiting
171 anon_send_exit(*worker, exit_reason::kill);
172}
173// --(rst-client-end)--
174
175void caf_main(actor_system& sys, const config& cfg) {

Callers

nothing calls this directly

Calls 8

make_messageFunction · 0.85
anon_send_exitFunction · 0.85
printlnMethod · 0.80
client_replFunction · 0.70
get_orFunction · 0.50
connectMethod · 0.45
middlemanMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected