Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: example in readme, license headers #614

Merged
merged 3 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,26 @@ Following example illustrates setup of Parallel Consumer with Meter Registry and

[source,java,indent=0]
----
ParallelStreamProcessor<String, String> setupParallelConsumer() {
Consumer<String, String> kafkaConsumer = getKafkaConsumer();

var options = ParallelConsumerOptions.<String, String>builder()
.ordering(ParallelConsumerOptions.ProcessingOrder.KEY)
.maxConcurrency(1000)
.consumer(kafkaConsumer)
.meterRegistry(meterRegistry) //<1>
.metricsTags(Tags.of(Tag.of("instance", "pc1"))) //<2>
.build();

ParallelStreamProcessor<String, String> eosStreamProcessor =
ParallelStreamProcessor.createEosStreamProcessor(options);

eosStreamProcessor.subscribe(of(inputTopic));

kafkaClientMetrics = new KafkaClientMetrics(kafkaConsumer); //<3>
kafkaClientMetrics.bindTo(meterRegistry); //<4>
return eosStreamProcessor;
}
----
<1> - Optional - Kafka Consumer Micrometer metrics object created for Kafka Consumer that is later used for Parallel Consumer.
<2> - Optional - Kafka Consumer Micrometer metrics are bound to Meter Registry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

import static java.util.Collections.emptyList;

@Slf4j
/**
* Main metrics collection and initialization service.
* Singleton - makes it easier to add metrics throughout the code
*/
@Slf4j
public class PCMetrics {
private static PCMetrics instance;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.confluent.parallelconsumer.offsets;

/*-
* Copyright (C) 2020-2022 Confluent, Inc.
* Copyright (C) 2020-2023 Confluent, Inc.
*/

import lombok.SneakyThrows;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.confluent.parallelconsumer.state;

/*-
* Copyright (C) 2020-2022 Confluent, Inc.
* Copyright (C) 2020-2023 Confluent, Inc.
*/

import io.confluent.csid.utils.KafkaUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.confluent.parallelconsumer;

/*-
* Copyright (C) 2020-2022 Confluent, Inc.
* Copyright (C) 2020-2023 Confluent, Inc.
*/

import io.confluent.parallelconsumer.internal.AbstractParallelEoSStreamProcessor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ protected void postSetup() {
}

@SuppressWarnings({"FeatureEnvy", "MagicNumber" })
// tag::example[]
ParallelStreamProcessor<String, String> setupParallelConsumer() {
Consumer<String, String> kafkaConsumer = getKafkaConsumer();

Expand All @@ -110,6 +111,7 @@ ParallelStreamProcessor<String, String> setupParallelConsumer() {
kafkaClientMetrics.bindTo(meterRegistry); //<4>
return eosStreamProcessor;
}
// end::example[]

void close() {
this.kafkaClientMetrics.close();
Expand Down