pub struct KafkaResource {
pub broker: String,
pub schema_registry_url: String,
pub topic: String,
/* private fields */
}Expand description
Kafka resource manager
Fields§
§broker: StringKafka broker address
schema_registry_url: StringSchema registry URL
topic: StringName of the isolated topic
Implementations§
Source§impl KafkaResource
impl KafkaResource
Sourcepub async fn new(
broker: &str,
schema_registry_url: &str,
topic: &str,
) -> Result<Self>
pub async fn new( broker: &str, schema_registry_url: &str, topic: &str, ) -> Result<Self>
Create a new Kafka resource with an isolated topic
Sourcepub async fn register_schema(&self, schema: &str) -> Result<u32>
pub async fn register_schema(&self, schema: &str) -> Result<u32>
Register an Avro schema for the topic
Sourcepub async fn produce_json_records<T: Serialize>(
&self,
records: &[T],
) -> Result<()>
pub async fn produce_json_records<T: Serialize>( &self, records: &[T], ) -> Result<()>
Produce JSON records to the topic (without schema registry)
Sourcepub async fn produce_avro_records<T: Serialize>(
&self,
records: &[T],
) -> Result<()>
pub async fn produce_avro_records<T: Serialize>( &self, records: &[T], ) -> Result<()>
Produce Avro records to the topic (with schema registry) Uses dbz.op=‘c’ (create/insert) header by default
Sourcepub async fn produce_avro_records_with_op<T: Serialize>(
&self,
records: &[T],
op: &str,
) -> Result<()>
pub async fn produce_avro_records_with_op<T: Serialize>( &self, records: &[T], op: &str, ) -> Result<()>
Produce Avro records with a specific debezium operation type op: “c” = create/insert, “u” = update, “d” = delete
Sourcepub async fn produce_raw(&self, records: &[Vec<u8>]) -> Result<()>
pub async fn produce_raw(&self, records: &[Vec<u8>]) -> Result<()>
Produce raw bytes to the topic
Sourcepub async fn inspect_topic_messages(
broker: &str,
schema_registry_url: &str,
topic: &str,
max_messages: usize,
max_show: usize,
) -> Result<(Vec<(i64, String, String)>, Option<i64>)>
pub async fn inspect_topic_messages( broker: &str, schema_registry_url: &str, topic: &str, max_messages: usize, max_show: usize, ) -> Result<(Vec<(i64, String, String)>, Option<i64>)>
Inspect messages in an existing topic without creating it Returns (messages, highest_offset) where messages are (offset, key, id_string) tuples
Trait Implementations§
Source§impl Drop for KafkaResource
impl Drop for KafkaResource
Auto Trait Implementations§
impl !RefUnwindSafe for KafkaResource
impl !UnwindSafe for KafkaResource
impl Freeze for KafkaResource
impl Send for KafkaResource
impl Sync for KafkaResource
impl Unpin for KafkaResource
impl UnsafeUnpin for KafkaResource
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreCreates a shared type from an unshared type.