-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The source's "domain" is ignored in jetstream.update_stream #1350
Comments
Hey! Thanks for the report. |
I cannot reproduce this. here is a simple (and ugly) test: #[tokio::test]
async fn stream_update_external() {
let server = nats_server::run_server("tests/configs/jetstream.conf");
let client = async_nats::connect(server.client_url()).await.unwrap();
let jetstream = async_nats::jetstream::new(client);
jetstream
.create_stream(stream::Config {
name: "origin".to_string(),
subjects: vec!["origin.>".to_string()],
..Default::default()
})
.await
.unwrap();
let mut stream = jetstream
.create_stream(stream::Config {
name: "events".to_string(),
subjects: vec!["events.>".to_string()],
..Default::default()
})
.await
.unwrap();
jetstream
.update_stream(stream::Config {
name: "events".to_string(),
subjects: vec!["events.>".to_string()],
sources: Some(vec![stream::Source {
name: "origin".to_string(),
external: Some(External {
api_prefix: "API.PREFIX".to_string(),
..Default::default()
}),
..Default::default()
}]),
..Default::default()
})
.await
.unwrap();
assert_eq!(
stream
.info()
.await
.unwrap()
.config
.sources
.as_ref()
.unwrap()[0]
.external
.as_ref()
.unwrap()
.api_prefix,
"API.PREFIX"
);
} Please keep in mind that the |
I may not have stated the problem clearly. The Here is the example code: #[tokio::test]
async fn stream_update_external() {
let client = async_nats::connect_with_options(
"localhost:4222",
async_nats::ConnectOptions::default()
.retry_on_initial_connect()
.user_and_password("user".to_string(), "user".to_string()),
)
.await
.unwrap();
let js = async_nats::jetstream::new(client);
let _ = js.delete_stream("test").await;
let mut stream = js
.create_stream(stream::Config {
name: "test".into(),
sources: Some(vec![stream::Source {
name: "source".into(),
domain: Some("domain".into()),
..Default::default()
}]),
..Default::default()
})
.await
.unwrap();
let stream_info = stream.info().await.unwrap();
assert_eq!(
stream_info.config.sources.as_ref().unwrap()[0]
.external
.as_ref()
.unwrap()
.api_prefix,
"$JS.domain.API"
);
js.update_stream(stream::Config {
sources: Some(vec![stream::Source {
name: "source".into(),
domain: Some("domain2".into()),
..Default::default()
}]),
..stream_info.config.clone()
}).await.unwrap();
let stream_info = stream.info().await.unwrap();
assert_eq!(
stream_info.config.sources.as_ref().unwrap()[0]
.external
.as_ref()
.unwrap()
.api_prefix,
"$JS.domain2.API"
);
} |
yes, this is correct. Please, as a workaround, use I will think how to address it in the best way. |
Observed behavior
After updating the stream with an external source, run
nats stream report
, theAPI Prefix
field is empty, andError
field containsstream not found (10059)
.This problem also exists in nats.go.
A possible cause:
There is domain-related logic in
create_stream
function, but not inupdate_stream
.nats.rs/async-nats/src/jetstream/context.rs
Lines 290 to 304 in 23bb978
nats.rs/async-nats/src/jetstream/context.rs
Lines 523 to 546 in 23bb978
Expected behavior
The
API Prefix
is correctly set to$JS.xxxx.API
.Server and client version
server: 2.10.23
client: 0.37.0
Host environment
No response
Steps to reproduce
No response
The text was updated successfully, but these errors were encountered: