pub trait ConsumerOffsetControl: Send + Sync {
Show 18 methods
// Required methods
async fn offset_store(&self) -> Option<Arc<OffsetStore>>;
async fn set_offset_store(
&self,
offset_store: Option<Arc<OffsetStore>>,
) -> ClientResult<()>;
async fn is_auto_commit(&self) -> bool;
async fn set_auto_commit(&self, auto_commit: bool);
async fn auto_commit_interval_millis(&self) -> u64;
async fn set_auto_commit_interval_millis(&self, interval_millis: u64);
async fn fetch_message_queues(
&self,
topic: &str,
) -> ClientResult<Vec<MessageQueue>>;
async fn offset_for_timestamp(
&self,
message_queue: &MessageQueue,
timestamp: u64,
) -> ClientResult<i64>;
async fn earliest_msg_store_time(
&self,
message_queue: &MessageQueue,
) -> ClientResult<i64>;
async fn max_offset(
&self,
message_queue: &MessageQueue,
) -> ClientResult<i64>;
async fn min_offset(
&self,
message_queue: &MessageQueue,
) -> ClientResult<i64>;
async fn commit_sync(&self);
async fn commit_sync_with_map(
&self,
offset_map: HashMap<MessageQueue, i64>,
persist: bool,
);
async fn commit(&self);
async fn commit_with_map(
&self,
offset_map: HashMap<MessageQueue, i64>,
persist: bool,
);
async fn commit_with_set(
&self,
message_queues: HashSet<MessageQueue>,
persist: bool,
);
async fn committed(&self, message_queue: &MessageQueue) -> ClientResult<i64>;
async fn commit_all(&self) -> ClientResult<()>;
}Required Methods§
Sourceasync fn offset_store(&self) -> Option<Arc<OffsetStore>>
async fn offset_store(&self) -> Option<Arc<OffsetStore>>
Returns the configured offset store, if one has been set or initialized.
Sourceasync fn set_offset_store(
&self,
offset_store: Option<Arc<OffsetStore>>,
) -> ClientResult<()>
async fn set_offset_store( &self, offset_store: Option<Arc<OffsetStore>>, ) -> ClientResult<()>
Sets the offset store used by the consumer.
This mirrors Java DefaultLitePullConsumer.setOffsetStore. The store
should be set before startup so load, rebalance, and commit paths share
the same backend.
Sourceasync fn is_auto_commit(&self) -> bool
async fn is_auto_commit(&self) -> bool
Returns whether automatic offset commit is enabled.
This function does not block the calling thread.
Sourceasync fn set_auto_commit(&self, auto_commit: bool)
async fn set_auto_commit(&self, auto_commit: bool)
Enables or disables automatic offset commit.
When auto-commit is enabled, offsets are committed periodically without explicit calls
to commit or commit_sync. When disabled, the caller is responsible for committing
offsets.
This function does not block the calling thread.
§Arguments
auto_commit-trueto enable automatic offset commit;falseto disable it.
Sourceasync fn auto_commit_interval_millis(&self) -> u64
async fn auto_commit_interval_millis(&self) -> u64
Returns the interval between automatic offset commits in milliseconds.
This function does not block the calling thread.
Sourceasync fn set_auto_commit_interval_millis(&self, interval_millis: u64)
async fn set_auto_commit_interval_millis(&self, interval_millis: u64)
Sets the interval between automatic offset commits in milliseconds.
Values below the Java client minimum of 1000ms are ignored, matching
DefaultLitePullConsumer.setAutoCommitIntervalMillis.
This function does not block the calling thread.
§Arguments
interval_millis- The new auto-commit interval in milliseconds.
Sourceasync fn fetch_message_queues(
&self,
topic: &str,
) -> ClientResult<Vec<MessageQueue>>
async fn fetch_message_queues( &self, topic: &str, ) -> ClientResult<Vec<MessageQueue>>
Queries the broker for all MessageQueues belonging to the specified topic.
This function does not block the calling thread.
§Arguments
topic- The name of the topic to query.
§Errors
Returns an error if the topic does not exist, if the name server is unreachable, or if the consumer is not in the running state.
Sourceasync fn offset_for_timestamp(
&self,
message_queue: &MessageQueue,
timestamp: u64,
) -> ClientResult<i64>
async fn offset_for_timestamp( &self, message_queue: &MessageQueue, timestamp: u64, ) -> ClientResult<i64>
Queries the broker for the offset corresponding to the given timestamp in a queue.
This function does not block the calling thread.
§Arguments
message_queue- The queue to query.timestamp- The Unix timestamp in milliseconds. The broker returns the offset of the first message stored at or after this timestamp.
§Errors
Returns an error if the queue is not found on the broker or the query fails.
Sourceasync fn earliest_msg_store_time(
&self,
message_queue: &MessageQueue,
) -> ClientResult<i64>
async fn earliest_msg_store_time( &self, message_queue: &MessageQueue, ) -> ClientResult<i64>
Queries the broker for the earliest message store time of the specified queue.
This function does not block the calling thread.
§Arguments
message_queue- The queue to query.
§Errors
Returns an error if the queue is not found on the broker, the consumer is not running, or this LitePull implementation does not support broker offset metadata queries.
Sourceasync fn max_offset(&self, message_queue: &MessageQueue) -> ClientResult<i64>
async fn max_offset(&self, message_queue: &MessageQueue) -> ClientResult<i64>
Queries the broker for the current maximum offset of the specified queue.
This function does not block the calling thread.
§Arguments
message_queue- The queue to query.
§Errors
Returns an error if the queue is not found on the broker, the consumer is not running, or this LitePull implementation does not support broker offset metadata queries.
Sourceasync fn min_offset(&self, message_queue: &MessageQueue) -> ClientResult<i64>
async fn min_offset(&self, message_queue: &MessageQueue) -> ClientResult<i64>
Queries the broker for the current minimum offset of the specified queue.
This function does not block the calling thread.
§Arguments
message_queue- The queue to query.
§Errors
Returns an error if the queue is not found on the broker, the consumer is not running, or this LitePull implementation does not support broker offset metadata queries.
Sourceasync fn commit_sync(&self)
async fn commit_sync(&self)
Commits all consumed offsets to the consumer offset store.
This function does not block the calling thread.
§Deprecation
This method is deprecated. The name implies broker-synchronous persistence, but Java
DefaultLitePullConsumer.commitSync() delegates to commitAll() and only updates the
consumer offset store. Use commit for the modern equivalent.
Sourceasync fn commit_sync_with_map(
&self,
offset_map: HashMap<MessageQueue, i64>,
persist: bool,
)
async fn commit_sync_with_map( &self, offset_map: HashMap<MessageQueue, i64>, persist: bool, )
Commits the provided offsets and optionally persists them to the broker.
This function does not block the calling thread.
§Deprecation
This method is deprecated. The name implies synchronous behavior, but the underlying
implementation relies on a background thread to commit offsets rather than committing
synchronously. Use commit_with_map instead.
§Arguments
offset_map- A map fromMessageQueueto the offset to commit.persist- Whentrue, the committed offsets are persisted to the broker immediately.
Sourceasync fn commit(&self)
async fn commit(&self)
Commits all consumed offsets to the consumer offset store.
This function does not block the calling thread. Broker or local-file persistence is
performed by the normal periodic persistence task, shutdown, or explicit
commit_with_map / commit_with_set calls with persist = true.
Sourceasync fn commit_with_map(
&self,
offset_map: HashMap<MessageQueue, i64>,
persist: bool,
)
async fn commit_with_map( &self, offset_map: HashMap<MessageQueue, i64>, persist: bool, )
Commits the provided offsets asynchronously, optionally persisting them to the broker.
This function does not block the calling thread.
§Arguments
offset_map- A map fromMessageQueueto the offset to commit.persist- Whentrue, the committed offsets are persisted to the broker.
Sourceasync fn commit_with_set(
&self,
message_queues: HashSet<MessageQueue>,
persist: bool,
)
async fn commit_with_set( &self, message_queues: HashSet<MessageQueue>, persist: bool, )
Commits the offsets for the specified subset of assigned queues.
This function does not block the calling thread.
§Arguments
message_queues- The queues whose current offsets are to be committed.persist- Whentrue, the committed offsets are persisted to the broker.
Sourceasync fn committed(&self, message_queue: &MessageQueue) -> ClientResult<i64>
async fn committed(&self, message_queue: &MessageQueue) -> ClientResult<i64>
Returns the last committed offset for the specified MessageQueue.
This function does not block the calling thread.
§Arguments
message_queue- The queue to query.
§Errors
Returns an error if the queue is not assigned to this consumer or if the offset cannot be retrieved from the offset store.
Sourceasync fn commit_all(&self) -> ClientResult<()>
async fn commit_all(&self) -> ClientResult<()>
Commits all consumed offsets for all assigned queues to the local offset store.
This method commits the current consumption offset for every assigned MessageQueue.
It follows the Java client commitAll() behavior: offsets are updated in the consumer’s
offset store, while broker or local-file persistence is handled by the normal periodic
persistence task, shutdown, or explicit commit_with_map / commit_with_set calls with
persist = true.
This function does not block the calling thread.
§Errors
Returns an error if the consumer is not in the running state.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".