Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kfollesdal
Copy link
Contributor

@kfollesdal kfollesdal commented Jan 26, 2026

  • Add configurable connection_timeout_secs and request_timeout_secs options (default: 10s each)
  • Verify that the stream exists before creating a consumer, providing a clear error if it doesn't
  • Improve error messages with more context for connection and consumer creation failures
  • Add tests for stream verification, timeout handling, and connection errors

Checklist

  • Documentation updated
  • Changelog updated

Breaking Changes?

Mark if you think the answer is yes for any of these components:

Describe Incompatible Changes

Copilot AI review requested due to automatic review settings January 26, 2026 16:48
@kfollesdal kfollesdal marked this pull request as draft January 26, 2026 16:48
Copy link
Contributor

Copilot AI left a 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_secs and request_timeout_secs to 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
Copy link

Copilot AI Jan 26, 2026

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.

Copilot uses AI. Check for mistakes.
#[serde(default, skip_serializing_if = "is_default")]
pub auth: Auth,

/// Connection timeout
Copy link

Copilot AI Jan 26, 2026

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.

Suggested change
/// Connection timeout
/// Connection timeout.

Copilot uses AI. Check for mistakes.
Comment on lines 379 to 408
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,
Copy link

Copilot AI Jan 26, 2026

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.

Suggested change
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,

Copilot uses AI. Check for mistakes.
@kfollesdal kfollesdal marked this pull request as ready for review January 26, 2026 16:53
@lalithsuresh lalithsuresh requested a review from blp January 26, 2026 17:04
@blp
Copy link
Member

blp commented Jan 28, 2026

@kfollesdal Please add Signed-off-by to these commits since we use the DCO.

Thank you! I'm continuing to review this.

Copy link
Member

@blp blp left a 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.

@kfollesdal
Copy link
Contributor Author

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.

@kfollesdal
Copy link
Contributor Author

@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.

@blp blp mentioned this pull request Jan 29, 2026
2 tasks
@blp
Copy link
Member

blp commented Jan 29, 2026

Closing this one because it's been copied into #5528 for merging.

@blp blp closed this Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants