Commit dbfc77ce authored by Dominik Charousset's avatar Dominik Charousset

Move config parameters to the modules

parent 31618916
...@@ -152,6 +152,7 @@ public: ...@@ -152,6 +152,7 @@ public:
/// Loads module `T` with optional template parameters `Ts...`. /// Loads module `T` with optional template parameters `Ts...`.
template <class T, class... Ts> template <class T, class... Ts>
actor_system_config& load() { actor_system_config& load() {
T::add_module_options(*this);
module_factories.push_back([](actor_system& sys) -> actor_system::module* { module_factories.push_back([](actor_system& sys) -> actor_system::module* {
return T::make(sys, detail::type_list<Ts...>{}); return T::make(sys, detail::type_list<Ts...>{});
}); });
...@@ -319,6 +320,11 @@ public: ...@@ -319,6 +320,11 @@ public:
static error parse_config(std::istream& source, const config_option_set& opts, static error parse_config(std::istream& source, const config_option_set& opts,
settings& result); settings& result);
/// @private
config_option_set& custom_options() {
return custom_options_;
}
protected: protected:
config_option_set custom_options_; config_option_set custom_options_;
......
...@@ -110,32 +110,6 @@ actor_system_config::actor_system_config() ...@@ -110,32 +110,6 @@ actor_system_config::actor_system_config()
.add<string>("format", "format for printed console lines") .add<string>("format", "format for printed console lines")
.add<string>("verbosity", "minimum severity level for console output") .add<string>("verbosity", "minimum severity level for console output")
.add<string_list>("excluded-components", "excluded components on console"); .add<string_list>("excluded-components", "excluded components on console");
opt_group{custom_options_, "caf.middleman"}
.add<std::string>("network-backend",
"either 'default' or 'asio' (if available)")
.add<std::vector<string>>("app-identifiers",
"valid application identifiers of this node")
.add<bool>("enable-automatic-connections",
"enables automatic connection management")
.add<size_t>("max-consecutive-reads",
"max. number of consecutive reads per broker")
.add<timespan>("heartbeat-interval", "interval of heartbeat messages")
.add<bool>("attach-utility-actors",
"schedule utility actors instead of dedicating threads")
.add<bool>("manual-multiplexing",
"disables background activity of the multiplexer")
.add<size_t>("workers", "number of deserialization workers");
opt_group(custom_options_, "caf.openssl")
.add<string>(openssl_certificate, "certificate",
"path to the PEM-formatted certificate file")
.add<string>(openssl_key, "key",
"path to the private key file for this node")
.add<string>(openssl_passphrase, "passphrase",
"passphrase to decrypt the private key")
.add<string>(openssl_capath, "capath",
"path to an OpenSSL-style directory of trusted certificates")
.add<string>(openssl_cafile, "cafile",
"path to a file of concatenated PEM-formatted certificates");
} }
settings actor_system_config::dump_content() const { settings actor_system_config::dump_content() const {
......
...@@ -261,6 +261,9 @@ public: ...@@ -261,6 +261,9 @@ public:
const char* in = nullptr, const char* in = nullptr,
bool reuse = false); bool reuse = false);
/// Adds module-specific options to the config before loading the module.
static void add_module_options(actor_system_config& cfg);
/// Returns a middleman using the default network backend. /// Returns a middleman using the default network backend.
static actor_system::module* make(actor_system&, detail::type_list<>); static actor_system::module* make(actor_system&, detail::type_list<>);
......
...@@ -86,6 +86,27 @@ void middleman::init_global_meta_objects() { ...@@ -86,6 +86,27 @@ void middleman::init_global_meta_objects() {
caf::init_global_meta_objects<id_block::io_module>(); caf::init_global_meta_objects<id_block::io_module>();
} }
void middleman::add_module_options(actor_system_config& cfg) {
config_option_adder{cfg.custom_options(), "caf.middleman"}
.add<std::string>("network-backend",
"either 'default' or 'asio' (if available)")
.add<std::vector<std::string>>("app-identifiers",
"valid application identifiers of this node")
.add<bool>("enable-automatic-connections",
"enables automatic connection management")
.add<size_t>("max-consecutive-reads",
"max. number of consecutive reads per broker")
.add<timespan>("heartbeat-interval", "interval of heartbeat messages")
.add<bool>("attach-utility-actors",
"schedule utility actors instead of dedicating threads")
.add<bool>("manual-multiplexing",
"disables background activity of the multiplexer")
.add<size_t>("workers", "number of deserialization workers");
config_option_adder{cfg.custom_options(), "caf.middleman.prometheus-http"}
.add<uint16_t>("port", "listening port for incoming scrapes")
.add<std::string>("address", "bind address for the HTTP server socket");
}
actor_system::module* middleman::make(actor_system& sys, detail::type_list<>) { actor_system::module* middleman::make(actor_system& sys, detail::type_list<>) {
auto impl = get_or(sys.config(), "caf.middleman.network-backend", auto impl = get_or(sys.config(), "caf.middleman.network-backend",
defaults::middleman::network_backend); defaults::middleman::network_backend);
......
...@@ -62,6 +62,9 @@ public: ...@@ -62,6 +62,9 @@ public:
/// of peers. /// of peers.
bool authentication_enabled(); bool authentication_enabled();
/// Adds module-specific options to the config before loading the module.
static void add_module_options(actor_system_config& cfg);
/// Returns an OpenSSL manager using the default network backend. /// Returns an OpenSSL manager using the default network backend.
/// @warning Creating an OpenSSL manager will fail when using /// @warning Creating an OpenSSL manager will fail when using
// a custom implementation. // a custom implementation.
......
...@@ -109,8 +109,7 @@ void manager::stop() { ...@@ -109,8 +109,7 @@ void manager::stop() {
manager_ = nullptr; manager_ = nullptr;
} }
void manager::init(actor_system_config&) { void manager::init(actor_system_config& cfg) {
CAF_LOG_TRACE("");
ERR_load_crypto_strings(); ERR_load_crypto_strings();
OPENSSL_add_all_algorithms_conf(); OPENSSL_add_all_algorithms_conf();
SSL_library_init(); SSL_library_init();
...@@ -150,6 +149,22 @@ bool manager::authentication_enabled() { ...@@ -150,6 +149,22 @@ bool manager::authentication_enabled() {
|| !cfg.openssl_cafile.empty(); || !cfg.openssl_cafile.empty();
} }
void manager::add_module_options(actor_system_config& cfg) {
config_option_adder(cfg.custom_options(), "caf.openssl")
.add<std::string>(cfg.openssl_certificate, "certificate",
"path to the PEM-formatted certificate file")
.add<std::string>(cfg.openssl_key, "key",
"path to the private key file for this node")
.add<std::string>(cfg.openssl_passphrase, "passphrase",
"passphrase to decrypt the private key")
.add<std::string>(
cfg.openssl_capath, "capath",
"path to an OpenSSL-style directory of trusted certificates")
.add<std::string>(
cfg.openssl_cafile, "cafile",
"path to a file of concatenated PEM-formatted certificates");
}
actor_system::module* manager::make(actor_system& sys, detail::type_list<>) { actor_system::module* manager::make(actor_system& sys, detail::type_list<>) {
if (!sys.has_middleman()) if (!sys.has_middleman())
CAF_RAISE_ERROR("Cannot start OpenSSL module without middleman."); CAF_RAISE_ERROR("Cannot start OpenSSL module without middleman.");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment