-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Experiment: extend Consumer and Function - centralises documentation …
…and makes usage more explicit rename step step
- Loading branch information
Showing
6 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
parallel-consumer-core/src/main/java/io/confluent/parallelconsumer/RecordProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
import org.apache.kafka.clients.consumer.ConsumerRecord; | ||
import org.apache.kafka.clients.producer.ProducerRecord; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Types of user functions used for processing records. | ||
*/ | ||
public interface RecordProcessor { | ||
|
||
/** | ||
* Process a Kafka {@link ConsumerRecord} via {@link PollContext} instances. | ||
*/ | ||
@FunctionalInterface | ||
interface PollConsumer<K, V> extends java.util.function.Consumer<PollContext<K, V>> { | ||
|
||
/** | ||
* Process a Kafka {@link ConsumerRecord} via {@link PollContext} instances. | ||
* <p> | ||
* User can throw a {@link PCRetriableException}, if an issue is and PC should handle the process of retrying it | ||
* later. If an exception is thrown that doesn't extend {@link PCRetriableException}, the error will be logged | ||
* at {@code WARN} level. | ||
* | ||
* @param records the Kafka records to process | ||
* @see PCRetriableException | ||
* @see ParallelConsumerOptions#getRetryDelayProvider() | ||
* @see ParallelConsumerOptions#getDefaultMessageRetryDelay() | ||
*/ | ||
void accept(PollContext records); | ||
} | ||
|
||
@FunctionalInterface | ||
interface PollConsumerAndProducer<K, V> extends java.util.function.Function<PollContext<K, V>, List<ProducerRecord<K, V>>> { | ||
|
||
/** | ||
* Like {@link PollConsumer#accept(PollContext)} but also returns records to be produced back to Kafka. | ||
* | ||
* @param records the Kafka records to process | ||
* @return the function result | ||
*/ | ||
@Override | ||
List<ProducerRecord<K, V>> apply(PollContext records); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters