constexpr std::string_view kSchema = R"~(
CREATE TABLE IF NOT EXISTS events_table (
id serial NOT NULL,
action VARCHAR PRIMARY KEY
)
)~";
public:
static constexpr std::string_view kName = "action-client";
: ComponentBase{config, context},
service_url_(config["service-url"].As<std::string>()),
auto CreateHttpRequest(std::string action) const {
}
return yaml_config::MergeSchemas<components::ComponentBase>(R"(
type: object
description: My dependencies schema
additionalProperties: false
properties:
service-url:
type: string
description: URL of the service to send the actions to
)");
}
private:
const std::string service_url_;
};
class ActionDep {
public:
auto CreateActionRequest(std::string action)
const {
return component_.
CreateHttpRequest(std::move(action)); }
app.
TryAddComponent<ActionClient>(ActionClient::kName,
"service-url: http://some-service.example/v1/action");
easy::HttpDep::RegisterOn(app);
}
private:
ActionClient& component_;
};
int main(int argc, char* argv[]) {
const auto& action = req.
GetArg(
"action");
deps.pg().Execute(
);
return deps.CreateActionRequest(action)->body();
});
}