-
Notifications
You must be signed in to change notification settings - Fork 98
[adapters] NATS: Add timout config and improv error context #5510
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds configurable timeout settings for the NATS adapter and improves error messaging to help users diagnose connection and configuration issues more easily.
Changes:
- Added configurable
connection_timeout_secsandrequest_timeout_secsto NATS connection options with 10-second defaults - Enhanced error messages throughout the NATS adapter to include relevant context (server URLs, stream names, timeout values)
- Added comprehensive tests to verify timeout behavior and error message clarity
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| crates/feldera-types/src/transport/nats.rs | Adds timeout configuration fields to ConnectOptions struct with default values and documentation |
| crates/adapters/src/transport/nats/input/config_utils.rs | Applies the new timeout settings when creating NATS connection options |
| crates/adapters/src/transport/nats/input.rs | Enhances error handling with contextual information and adds early stream validation |
| crates/adapters/src/transport/nats/input/test.rs | Adds tests for connection timeout behavior and error message validation |
| #[serde(default, skip_serializing_if = "is_default")] | ||
| pub auth: Auth, | ||
|
|
||
| /// Connection timeout |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected spelling of 'timout' to 'timeout' in PR title. The code itself is correctly spelled.
| #[serde(default, skip_serializing_if = "is_default")] | ||
| pub auth: Auth, | ||
|
|
||
| /// Connection timeout |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is missing a period at the end, while line 65 includes one. The documentation should be consistent in punctuation style across similar fields.
| /// Connection timeout | |
| /// Connection timeout. |
| jetstream | ||
| .create_consumer_strict_on_stream(consumer_config.clone(), stream_name) | ||
| .await | ||
| .with_context(|| { | ||
| format!( | ||
| "Failed to create consumer on stream '{}' (start_sequence={}, deliver_policy={:?}, filter_subjects={:?})", | ||
| stream_name, | ||
| message_start_sequence, | ||
| consumer_config.deliver_policy, | ||
| consumer_config.filter_subjects, |
Copilot
AI
Jan 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consumer_config is cloned here only to be used in the error message context. Consider restructuring to avoid the clone, as the config is only needed for display purposes in the error path.
| jetstream | |
| .create_consumer_strict_on_stream(consumer_config.clone(), stream_name) | |
| .await | |
| .with_context(|| { | |
| format!( | |
| "Failed to create consumer on stream '{}' (start_sequence={}, deliver_policy={:?}, filter_subjects={:?})", | |
| stream_name, | |
| message_start_sequence, | |
| consumer_config.deliver_policy, | |
| consumer_config.filter_subjects, | |
| let error_deliver_policy = consumer_config.deliver_policy.clone(); | |
| let error_filter_subjects = consumer_config.filter_subjects.clone(); | |
| jetstream | |
| .create_consumer_strict_on_stream(consumer_config, stream_name) | |
| .await | |
| .with_context(|| { | |
| format!( | |
| "Failed to create consumer on stream '{}' (start_sequence={}, deliver_policy={:?}, filter_subjects={:?})", | |
| stream_name, | |
| message_start_sequence, | |
| error_deliver_policy, | |
| error_filter_subjects, |
cb44955 to
dbcd93d
Compare
|
@kfollesdal Please add Signed-off-by to these commits since we use the DCO. Thank you! I'm continuing to review this. |
blp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks straightforward, thanks! Special thanks for adding tests and error message context.,
You might consider adding key parts of the configuration (such as the stream name or server url?) to the info_span!() call, because that will make them part of all the log messages that the span instruments. That can be really useful, especially if there are multiple nats connectors.
I'll start the process of merging this once the DCOs are available.
|
God suggestion to add more from the configuration to info_span!() call for better context, I will add that and also check your timeout question. |
Signed-off-by: kfollesdal <[email protected]>
Signed-off-by: kfollesdal <[email protected]>
Signed-off-by: kfollesdal <[email protected]>
…ection error Signed-off-by: kfollesdal <[email protected]>
…reation Signed-off-by: kfollesdal <[email protected]>
Signed-off-by: kfollesdal <[email protected]>
dbcd93d to
bd082f3
Compare
|
@blp, commits is signed and I have added more identifying info to the span and timeout question checked. I see that one practical thing to add to the info_span is the connector name, that would be the best identify. But that was not easy available without change code outside the nats connector, if I understand it correct. |
|
Closing this one because it's been copied into #5528 for merging. |
Checklist
Breaking Changes?
Mark if you think the answer is yes for any of these components:
Describe Incompatible Changes