Skip to content

Commit 2070545

Browse files
committed
feat kafka: document task processors and allow their customization
Tests: протестировано CI commit_hash:1363ff2b1222d56624aa9e6f7708859d8b50f480
1 parent ae0a15f commit 2070545

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

kafka/src/kafka/consumer_component.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ USERVER_NAMESPACE_BEGIN
1818

1919
namespace kafka {
2020

21+
namespace {
22+
23+
std::string TaskProcessorName(std::string_view name, const components::ComponentConfig& config) {
24+
return config[name].As<std::string>(name);
25+
}
26+
27+
} // namespace
28+
2129
ConsumerComponent::ConsumerComponent(
2230
const components::ComponentConfig& config,
2331
const components::ComponentContext& context
@@ -26,9 +34,9 @@ ConsumerComponent::ConsumerComponent(
2634
consumer_(
2735
config.Name(),
2836
config["topics"].As<std::vector<std::string>>(),
29-
context.GetTaskProcessor("consumer-task-processor"),
30-
context.GetTaskProcessor("consumer-blocking-task-processor"),
31-
context.GetTaskProcessor("main-task-processor"),
37+
context.GetTaskProcessor(TaskProcessorName("consumer-task-processor", config)),
38+
context.GetTaskProcessor(TaskProcessorName("consumer-blocking-task-processor", config)),
39+
context.GetTaskProcessor(config["task-processor"].As<std::string>("main-task-processor")),
3240
config.As<impl::ConsumerConfiguration>(),
3341
context.FindComponent<components::Secdist>()
3442
.Get()

kafka/src/kafka/consumer_component.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@ type: object
22
description: Kafka consumer component
33
additionalProperties: false
44
properties:
5+
task-processor:
6+
type: string
7+
description: the name of the TaskProcessor to invoke callbacks
8+
default: main-task-processor
9+
consumer-task-processor:
10+
type: string
11+
description: TaskProcessor for message batches polling. Feel free to use 'main-task-processor'.
12+
default: consumer-task-processor
13+
consumer-blocking-task-processor:
14+
type: string
15+
description: TaskProcessor for consumer blocking operations. Feel free to use 'fs-task-processor'.
16+
default: consumer-blocking-task-processor
517
group_id:
618
type: string
719
description: |

0 commit comments

Comments
 (0)