Ejemplo n.º 1
0
pool_ptr pool(context_t& context, const std::string& name) {
    auto pool = context.config().component_group("postgres").get(name);
    if(!pool) {
        throw error_t(std::errc::argument_out_of_domain, "postgres component with name '{}' not found", name);
    }
    return context.repository().get<pool_t>("postgres", context, name, pool->args());
}
Ejemplo n.º 2
0
/**
 * Unicorn trait for service creation.
 * Trait to create unicorn service by name. All instances are cached by name as it is done in storage.
 */
unicorn_ptr
unicorn(context_t& context, const std::string& name) {
    auto unicorn = context.config().unicorns().get(name);
    if(!unicorn) {
        throw error_t(error::component_not_found, "unicorn component \"{}\" not found in the config", name);
    }
    return context.repository().get<unicorn_t>(unicorn->type(), context, name, unicorn->args());
}