Skip to content

Commit

Permalink
ConsumerSeekAware default implementations
Browse files Browse the repository at this point in the history
Add default method implementations to avoid users having to implement
methods they are not interested in.
  • Loading branch information
garyrussell authored and artembilan committed May 8, 2019
1 parent 80388da commit fc5d433
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
Expand Up @@ -37,22 +37,28 @@ public interface ConsumerSeekAware {
* containers listeners should store the callback in a {@code ThreadLocal}.
* @param callback the callback.
*/
void registerSeekCallback(ConsumerSeekCallback callback);
default void registerSeekCallback(ConsumerSeekCallback callback) {
// do nothing
}

/**
* When using group management, called when partition assignments change.
* @param assignments the new assignments and their current offsets.
* @param callback the callback to perform an initial seek after assignment.
*/
void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);
default void onPartitionsAssigned(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback) {
// do nothing
}

/**
* If the container is configured to emit idle container events, this method is called
* when the container idle event is emitted - allowing a seek operation.
* @param assignments the new assignments and their current offsets.
* @param callback the callback to perform a seek.
*/
void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback);
default void onIdleContainer(Map<TopicPartition, Long> assignments, ConsumerSeekCallback callback) {
// do nothing
}

/**
* A callback that a listener can invoke to seek to a specific offset.
Expand Down
Expand Up @@ -1689,18 +1689,6 @@ public void registerSeekCallback(ConsumerSeekCallback callback) {
this.seekCallBack.set(callback);
}

@Override
public void onPartitionsAssigned(Map<org.apache.kafka.common.TopicPartition, Long> assignments,
ConsumerSeekCallback callback) {
// NOSONAR
}

@Override
public void onIdleContainer(Map<org.apache.kafka.common.TopicPartition, Long> assignments,
ConsumerSeekCallback callback) {
// NOSONAR
}

}

interface IfaceListener<T> {
Expand Down

0 comments on commit fc5d433

Please sign in to comment.