Skip to content

Commit

Permalink
Merge pull request #146 from project-tsurugi/wip/i_469
Browse files Browse the repository at this point in the history
fix ipc_endpoint::setup() returns error when database_name is empty
  • Loading branch information
t-horikawa authored Nov 21, 2023
2 parents dc8468c + 5ac37d1 commit 3512dad
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
17 changes: 11 additions & 6 deletions src/tateyama/endpoint/ipc/bootstrap/ipc_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ class ipc_endpoint : public endpoint {
* @brief setup the component (the state will be `ready`)
*/
bool setup(environment& env) override {
// create listener object
listener_ = std::make_unique<tateyama::server::ipc_listener>(
env.configuration(),
env.service_repository().find<framework::routing_service>(),
env.resource_repository().find<status_info::resource::bridge>()
);
try {
// create listener object
listener_ = std::make_unique<tateyama::server::ipc_listener>(
env.configuration(),
env.service_repository().find<framework::routing_service>(),
env.resource_repository().find<status_info::resource::bridge>()
);
} catch (std::runtime_error &ex) {
LOG_LP(ERROR) << ex.what();
return false;
}
return true;
}

Expand Down
18 changes: 8 additions & 10 deletions src/tateyama/endpoint/ipc/bootstrap/ipc_listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,36 +45,34 @@ class ipc_listener {
{
auto endpoint_config = cfg->get_section("ipc_endpoint");
if (endpoint_config == nullptr) {
LOG_LP(ERROR) << "cannot find ipc_endpoint section in the configuration";
exit(1);
throw std::runtime_error("cannot find ipc_endpoint section in the configuration");
}

auto database_name_opt = endpoint_config->get<std::string>("database_name");
if (!database_name_opt) {
LOG_LP(ERROR) << "cannot find database_name at the section in the configuration";
exit(1);
throw std::runtime_error("cannot find database_name at the section in the configuration");
}
database_name_ = database_name_opt.value();
if (database_name_.empty()) {
throw std::runtime_error("database_name in ipc_endpoint section should not be empty");
}

auto threads_opt = endpoint_config->get<std::size_t>("threads");
if (!threads_opt) {
LOG_LP(ERROR) << "cannot find thread_pool_size at the section in the configuration";
exit(1);
throw std::runtime_error("cannot find thread_pool_size at the section in the configuration");
}
auto threads = threads_opt.value();

auto datachannel_buffer_size_opt = endpoint_config->get<std::size_t>("datachannel_buffer_size");
if (!datachannel_buffer_size_opt) {
LOG_LP(ERROR) << "cannot find datachannel_buffer_size at the section in the configuration";
exit(1);
throw std::runtime_error("cannot find datachannel_buffer_size at the section in the configuration");
}
datachannel_buffer_size_ = datachannel_buffer_size_opt.value() * 1024; // in KB
VLOG_LP(log_debug) << "datachannel_buffer_size = " << datachannel_buffer_size_ << " bytes";

auto max_datachannel_buffers_opt = endpoint_config->get<std::size_t>("max_datachannel_buffers");
if (!max_datachannel_buffers_opt) {
LOG_LP(ERROR) << "cannot find max_datachannel_buffers at the section in the configuration";
exit(1);
throw std::runtime_error("cannot find max_datachannel_buffers at the section in the configuration");
}
max_datachannel_buffers_ = max_datachannel_buffers_opt.value();
VLOG_LP(log_debug) << "max_datachannel_buffers = " << max_datachannel_buffers_;
Expand Down

0 comments on commit 3512dad

Please sign in to comment.