40
loading...
This website collects cookies to deliver better user experience
compacted
such that the last message with the same key will never be deleted.schema_registry_converter
library.schema_registry_converter
came into existence creating a Rust variant for the Command Handler
part of the demo project. For that project I was using schema registry, and since I wanted to keep the rest of the system the same, I didn't want to change the binary format used with Kafka.async
. This might improve performance of your app, and is also the default for the major Kafka client, more information about why you would want to use async can be found in the async book. The schemas retrieved from the Schema Registry are cached. This way the schema is only retrieved once for each id, and reused for other messages with the same id.SubjectNameStrategies
which might contain a schema. With the option of using the cache, a byte value is produced that can be used as either the key
or value
part of a Kafka record.key
or value
bytes is used. With the encoded id the matching schema will be retrieved or fetched from the cache. Depending on the decoder used a certain typed value is returned. Depending on the app this value can be used for several things, for example to write something in a database.AvroData
in the demo project.use avro_rs::types::Value;
use schema_registry_converter::async_impl::schema_registry::SrSettings;
use schema_registry_converter::async_impl::avro::AvroDecoder;
async fn test() {
let sr_settings = SrSettings::new(format!("http://{}", server_address()));
let mut decoder = AvroDecoder::new(sr_settings);
let heartbeat = decoder.decode(Some(&[0, 0, 0, 0, 1, 6])).await.unwrap().value;
assert_eq!(heartbeat, Value::Record(vec![("beat".to_string(), Value::Long(3))]));
}