Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clients/cloud/rust/src/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let (topic, mut config) = utils::get_config()?;
let consumer: StreamConsumer = config.set("group.id", "rust_example_group_1").create()?;

consumer.subscribe(&vec![topic.as_ref()])?;
consumer.subscribe(&[&topic])?;

let processor = consumer
.start()
Expand Down
4 changes: 2 additions & 2 deletions clients/cloud/rust/src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ fn log_produce_result(
result: Result<(i32, i64), (KafkaError, OwnedMessage)>,
) -> Result<(), ()> {
result
.and_then(|(p, o)| {
.map(|(p, o)| {
println!(
"Successfully produced record to topic {} partition [{}] @ offset {}",
topic, p, o
);
Ok(())

})
.map_err(|(err, _)| eprintln!("kafka error: {}", err))
}
Expand Down
6 changes: 3 additions & 3 deletions clients/cloud/rust/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;

pub fn get_config() -> Result<(String, ClientConfig), Box<std::error::Error>> {
pub fn get_config() -> Result<(String, ClientConfig), Box<dyn std::error::Error>> {
let matches = App::new("rust client example")
.version(option_env!("CARGO_PKG_VERSION").unwrap_or(""))
.arg(
Expand All @@ -44,10 +44,10 @@ pub fn get_config() -> Result<(String, ClientConfig), Box<std::error::Error>> {
let file = File::open(matches.value_of("config").ok_or("error parsing config")?)?;
for line in BufReader::new(&file).lines() {
let cur_line: String = line?.trim().to_string();
if cur_line.starts_with('#') || cur_line.len() < 1 {
if cur_line.starts_with('#') || cur_line.is_empty() {
continue;
}
let key_value: Vec<&str> = cur_line.split("=").collect();
let key_value: Vec<&str> = cur_line.split('=').collect();
kafka_config.set(
key_value.get(0).ok_or("malformed key")?,
key_value.get(1).ok_or("malformed value")?,
Expand Down