pub struct SourceConsumer { /* private fields */ }Expand description
A [Source] implementation backed by a Kafka consumer on the source cluster.
This type wraps a Consumer and translates each
krabka_client_consumer::ConsumerRecord into a ReplicatedRecord. That
record carries the full envelope of topic, partition, offset, timestamp, and
headers next to the raw payload. The connect runtime receives the whole
ReplicatedRecord value, including the source coordinates that offset-sync
generation needs.
Implementations§
Source§impl SourceConsumer
impl SourceConsumer
Sourcepub async fn start(
bootstrap: &str,
group_id: &str,
topics: &[String],
security: Option<ClientSecurity>,
) -> Result<Self, ConnectError>
pub async fn start( bootstrap: &str, group_id: &str, topics: &[String], security: Option<ClientSecurity>, ) -> Result<Self, ConnectError>
Build and start a SourceConsumer that subscribes to topics on the
cluster at bootstrap and joins group_id.
Offsets reset to earliest, because the group has no previously committed
offset. Pass security when the source cluster needs authentication or
TLS.
§Errors
Returns [ConnectError::Backend] if the consumer cannot join the group.
Sourcepub async fn start_with_policy(
bootstrap: &str,
group_id: &str,
topics: &[String],
security: Option<ClientSecurity>,
client_resource_policy: ClientResourcePolicy,
) -> Result<Self, ConnectError>
pub async fn start_with_policy( bootstrap: &str, group_id: &str, topics: &[String], security: Option<ClientSecurity>, client_resource_policy: ClientResourcePolicy, ) -> Result<Self, ConnectError>
Build with the deployment’s client resource policy.
§Errors
Returns a [ConnectError] if the consumer cannot connect.
Trait Implementations§
Source§impl Source<(), ReplicatedRecord> for SourceConsumer
impl Source<(), ReplicatedRecord> for SourceConsumer
Source§fn poll<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<ConnectRecord<(), ReplicatedRecord>>, ConnectError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn poll<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<Option<ConnectRecord<(), ReplicatedRecord>>, ConnectError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Poll the source cluster for the next record.
Returns Ok(None) when the consumer is momentarily caught up. The
runtime should back off and retry. Returns Ok(Some(_)) with the
next ReplicatedRecord in every other case.
§Errors
Returns [ConnectError::Backend] if the underlying consumer poll fails.
Source§fn checkpoint(&self) -> Option<SourceOffset>
fn checkpoint(&self) -> Option<SourceOffset>
Snapshot the current read positions for all partitions seen so far.
Returns None before the first successful poll, when there is nothing to
commit yet.
Source§fn seek<'life0, 'async_trait>(
&'life0 mut self,
offset: SourceOffset,
) -> Pin<Box<dyn Future<Output = Result<(), ConnectError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn seek<'life0, 'async_trait>(
&'life0 mut self,
offset: SourceOffset,
) -> Pin<Box<dyn Future<Output = Result<(), ConnectError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Restore the read position from a previously-checkpointed [SourceOffset].
The runtime calls this method once before the first poll
and passes the position that it loaded from the durable checkpoint store
on the target. Each position entry maps the key
"<topic>-<partition>" to [OffsetValue::Long](next_offset), the
value that checkpoint wrote as last_consumed + 1.
This method decodes each key back into (topic, partition) and hands the
offset to the seek of the
consumer.
The consumer holds each seek as pending. It materialises the seek at
the top of the first poll that sees the partition assigned, after the
post-assignment offset prime of the group but before any Fetch. The
sought offset is therefore the offset that the consumer fetches. A
restart then resumes from the last fully-committed record and does
not re-read the topic from offset 0. No record below the sought offset is
re-delivered and no record above it is skipped, so there is no data gap.
An at-least-once flow can re-deliver a batch after a crash between the
sink flush and checkpoint save. An exactly-once flow writes this same
position inside the target producer transaction, so output and recovery
position become visible together.
This method skips a malformed key with a warning and does not fail the
restore. A malformed key has no -, or a non-integer partition or
offset. One corrupt entry must not strand recovery for the partitions
that decoded cleanly.
§Errors
Returns [ConnectError::Backend] if the consumer is already closed.
Source§fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ConnectError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn close<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), ConnectError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close the underlying consumer. The close sends LeaveGroup, so a
restarted replicator can rejoin the group immediately and does not wait
out the session timeout of the departed member.
§Errors
Returns [ConnectError::Backend] if the consumer fails to close cleanly.
§fn acknowledge<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_offset: &'life1 SourceOffset,
) -> Pin<Box<dyn Future<Output = Result<(), ConnectError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn acknowledge<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_offset: &'life1 SourceOffset,
) -> Pin<Box<dyn Future<Output = Result<(), ConnectError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
offset is durable end-to-end. Read moreAuto Trait Implementations§
impl !Freeze for SourceConsumer
impl !RefUnwindSafe for SourceConsumer
impl !UnwindSafe for SourceConsumer
impl Send for SourceConsumer
impl Sync for SourceConsumer
impl Unpin for SourceConsumer
impl UnsafeUnpin for SourceConsumer
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);