Skip to content

Commit

Permalink
Remove check for server compatibility from consumer create
Browse files Browse the repository at this point in the history
Checking server version is not a reliable way to know if given
API call is supported for given context, as client might be connected
to a leaf node, while the meta leader is a different version, part of
different cluster.

Signed-off-by: Tomasz Pietrek <[email protected]>
  • Loading branch information
Jarema committed May 27, 2024
1 parent 4c81c96 commit 8c89006
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions async-nats/src/jetstream/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,32 +1003,17 @@ impl Context {
let config = config.into_consumer_config();

let subject = {
if self.client.is_server_compatible(2, 9, 0) {
let filter = if config.filter_subject.is_empty() {
"".to_string()
} else {
format!(".{}", config.filter_subject)
};
config
.name
.as_ref()
.or(config.durable_name.as_ref())
.map(|name| format!("CONSUMER.CREATE.{}.{}{}", stream.as_ref(), name, filter))
.unwrap_or_else(|| format!("CONSUMER.CREATE.{}", stream.as_ref()))
} else if config.name.is_some() {
return Err(ConsumerError::with_source(
ConsumerErrorKind::Other,
"can't use consumer name with server < 2.9.0",
));
} else if let Some(ref durable_name) = config.durable_name {
format!(
"CONSUMER.DURABLE.CREATE.{}.{}",
stream.as_ref(),
durable_name
)
let filter = if config.filter_subject.is_empty() {
"".to_string()
} else {
format!("CONSUMER.CREATE.{}", stream.as_ref())
}
format!(".{}", config.filter_subject)
};
config
.name
.as_ref()
.or(config.durable_name.as_ref())
.map(|name| format!("CONSUMER.CREATE.{}.{}{}", stream.as_ref(), name, filter))
.unwrap_or_else(|| format!("CONSUMER.CREATE.{}", stream.as_ref()))
};

match self
Expand Down

0 comments on commit 8c89006

Please sign in to comment.