|
CAF 0.17.6
|
Manages brokers and network backends. More...
#include <middleman.hpp>
Public Types | |
| using | backend_pointer = std::unique_ptr< network::multiplexer > |
Smart pointer for network::multiplexer. | |
| using | backend_factory = std::function< backend_pointer()> |
| Used to initialize the backend during construction. | |
Public Types inherited from caf::actor_system::module | |
| enum | id_t { scheduler , middleman , opencl_manager , openssl_manager , network_manager , num_ids } |
Public Member Functions | |
| expected< uint16_t > | open (uint16_t port, const char *in=nullptr, bool reuse=false) |
| Tries to open a port for other CAF instances to connect to. | |
| expected< void > | close (uint16_t port) |
Closes port port regardless of whether an actor is published to it. | |
| expected< node_id > | connect (std::string host, uint16_t port) |
| Tries to connect to given node. | |
| template<class Handle > | |
| expected< uint16_t > | publish (Handle &&whom, uint16_t port, const char *in=nullptr, bool reuse=false) |
Tries to publish whom at port and returns either an error or the bound port. | |
| expected< uint16_t > | publish_local_groups (uint16_t port, const char *in=nullptr, bool reuse=false) |
Makes all local groups accessible via network on address addr and port. | |
| template<class Handle > | |
| expected< void > | unpublish (const Handle &whom, uint16_t port=0) |
Unpublishes whom by closing port or all assigned ports if port == 0. | |
| template<class ActorHandle = actor> | |
| expected< ActorHandle > | remote_actor (std::string host, uint16_t port) |
Establish a new connection to the actor at host on given port. | |
| expected< group > | remote_group (const std::string &group_uri) |
| <group-name><host>:<port> | |
| expected< group > | remote_group (const std::string &group_identifier, const std::string &host, uint16_t port) |
| actor_system & | system () |
| Returns the enclosing actor system. | |
| const actor_system_config & | config () const |
| Returns the systemw-wide configuration. | |
| middleman_actor | actor_handle () |
| Returns a handle to the actor managing the middleman singleton. | |
| template<class Impl > | |
| actor | named_broker (atom_value name) |
Returns the broker associated with name or creates a new instance of type Impl. | |
| template<class F > | |
| void | run_later (F fun) |
Runs fun in the event loop of the middleman. | |
| virtual network::multiplexer & | backend ()=0 |
| Returns the IO backend used by this middleman. | |
| strong_actor_ptr | remote_lookup (atom_value name, const node_id &nid) |
Returns the actor associated with name at nid or invalid_actor if nid is not connected or has no actor associated to this name. | |
| template<class Handle > | |
| expected< Handle > | remote_spawn (const node_id &nid, std::string name, message args, duration timeout=duration(time_unit::minutes, 1)) |
| template<class Handle , class Rep , class Period > | |
| expected< Handle > | remote_spawn (const node_id &nid, std::string name, message args, std::chrono::duration< Rep, Period > timeout) |
| void | start () override |
| Starts any background threads needed by the module. | |
| void | stop () override |
| Stops all background threads of the module. | |
| void | init (actor_system_config &) override |
| Allows the module to change the configuration of the actor system during startup. | |
| id_t | id () const override |
| Returns the identifier of this module. | |
| void * | subtype_ptr () override |
| Returns a pointer to the subtype. | |
| template<spawn_options Os = no_spawn_options, class F = std::function<void(broker*)>, class... Ts> | |
| infer_handle_from_fun< F >::type | spawn_broker (F fun, Ts &&... xs) |
| Spawns a new functor-based broker. | |
| template<spawn_options Os = no_spawn_options, class F = std::function<void(broker*)>, class... Ts> | |
| expected< typename infer_handle_from_fun< F >::type > | spawn_client (F fun, const std::string &host, uint16_t port, Ts &&... xs) |
Returns a new functor-based broker connected to host:port or an error. | |
| template<spawn_options Os = no_spawn_options, class F = std::function<void(broker*)>, class... Ts> | |
| expected< typename infer_handle_from_fun< F >::type > | spawn_server (F fun, uint16_t &port, Ts &&... xs) |
Spawns a new broker as server running on given port. | |
| template<spawn_options Os = no_spawn_options, class F = std::function<void(broker*)>, class... Ts> | |
| expected< typename infer_handle_from_fun< F >::type > | spawn_server (F fun, const uint16_t &port, Ts &&... xs) |
Spawns a new broker as server running on given port. | |
Public Member Functions inherited from caf::actor_system::module | |
| const char * | name () const noexcept |
| Returns the human-redable name of the module. | |
Static Public Member Functions | |
| static actor_system::module * | make (actor_system &, detail::type_list<>) |
| Returns a middleman using the default network backend. | |
| template<class Backend > | |
| static actor_system::module * | make (actor_system &sys, detail::type_list< Backend >) |
Protected Member Functions | |
| middleman (actor_system &sys) | |
Friends | |
| class | ::caf::actor_system |
Manages brokers and network backends.
Tries to connect to given node.
|
overridevirtual |
Returns the identifier of this module.
Implements caf::actor_system::module.
|
overridevirtual |
Allows the module to change the configuration of the actor system during startup.
Implements caf::actor_system::module.
| expected< uint16_t > caf::io::middleman::open | ( | uint16_t | port, |
| const char * | in = nullptr, |
||
| bool | reuse = false |
||
| ) |
Tries to open a port for other CAF instances to connect to.
| expected< uint16_t > caf::io::middleman::publish | ( | Handle && | whom, |
| uint16_t | port, | ||
| const char * | in = nullptr, |
||
| bool | reuse = false |
||
| ) |
Tries to publish whom at port and returns either an error or the bound port.
| whom | Actor that should be published at port. |
| port | Unused TCP port. |
| in | The IP address to listen to or INADDR_ANY if in == nullptr. |
| reuse | Create socket using SO_REUSEADDR. |
bind(). If port == 0 the OS chooses a random high-level port. | expected< uint16_t > caf::io::middleman::publish_local_groups | ( | uint16_t | port, |
| const char * | in = nullptr, |
||
| bool | reuse = false |
||
| ) |
Makes all local groups accessible via network on address addr and port.
bind(). If port == 0 the OS chooses a random high-level port. | expected< ActorHandle > caf::io::middleman::remote_actor | ( | std::string | host, |
| uint16_t | port | ||
| ) |
Establish a new connection to the actor at host on given port.
| host | Valid hostname or IP address. |
| port | TCP port. |
actor to the proxy instance representing a remote actor or an error. | strong_actor_ptr caf::io::middleman::remote_lookup | ( | atom_value | name, |
| const node_id & | nid | ||
| ) |
Returns the actor associated with name at nid or invalid_actor if nid is not connected or has no actor associated to this name.
nid responded to the lookup or an error occurred. | expected< Handle > caf::io::middleman::remote_spawn | ( | const node_id & | nid, |
| std::string | name, | ||
| message | args, | ||
| duration | timeout = duration(time_unit::minutes, 1) |
||
| ) |
| expected< Handle > caf::io::middleman::remote_spawn | ( | const node_id & | nid, |
| std::string | name, | ||
| message | args, | ||
| std::chrono::duration< Rep, Period > | timeout | ||
| ) |
Runs fun in the event loop of the middleman.
| expected< typename infer_handle_from_fun< F >::type > caf::io::middleman::spawn_client | ( | F | fun, |
| const std::string & | host, | ||
| uint16_t | port, | ||
| Ts &&... | xs | ||
| ) |
Returns a new functor-based broker connected to host:port or an error.
| expected< typename infer_handle_from_fun< F >::type > caf::io::middleman::spawn_server | ( | F | fun, |
| const uint16_t & | port, | ||
| Ts &&... | xs | ||
| ) |
Spawns a new broker as server running on given port.
| expected< typename infer_handle_from_fun< F >::type > caf::io::middleman::spawn_server | ( | F | fun, |
| uint16_t & | port, | ||
| Ts &&... | xs | ||
| ) |
Spawns a new broker as server running on given port.
|
overridevirtual |
Starts any background threads needed by the module.
Implements caf::actor_system::module.
|
overridevirtual |
Stops all background threads of the module.
Implements caf::actor_system::module.
|
overridevirtual |
Returns a pointer to the subtype.
Implements caf::actor_system::module.
Unpublishes whom by closing port or all assigned ports if port == 0.
| whom | Actor that should be unpublished at port. |
| port | TCP port. |