#include <producer_handler.hpp>
#include <userver/kafka/producer_component.hpp>
#include <userver/components/component_config.hpp>
#include <produce.hpp>
namespace kafka_sample {
RequestMessage request_message;
request_message.topic = doc[
"topic"].
As<std::string>();
request_message.key = doc[
"key"].
As<std::string>();
request_message.payload = doc[
"payload"].
As<std::string>();
return request_message;
}
namespace {
constexpr std::string_view kReqTopicFieldName = "topic";
constexpr std::string_view kReqKeyFieldName = "key";
constexpr std::string_view kReqPayloadFieldName = "payload";
constexpr std::string_view kErrorMembersNotSet = R"(
{
"error": "Expected body has `topic`, `key` and `payload` fields"
}
)";
return request_json.
HasMember(kReqPayloadFieldName) && request_json.
HasMember(kReqTopicFieldName) &&
}
}
) const {
if (!IsCorrectRequest(request_json)) {
}
const auto message = request_json.
As<RequestMessage>();
switch (Produce(producer_, message)) {
case SendStatus::kSuccess:
case SendStatus::kErrorRetryable:
case SendStatus::kErrorNonRetryable:
}
}
}