Add timeout configuration options for connector operations#81
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds configurable operation timeouts across connectors in Ratatosk (send, receive, status query), including new configuration primitives, timeout-specific error codes/logging, and test utilities to validate timeout/telemetry behavior.
Changes:
- Introduces
TimeoutOptions+TimeoutSettingsKeysand a fluentWithTimeout(...)builder API for configuring connector timeouts. - Integrates cancellation-based timeout enforcement into
ChannelConnectorBasesend/receive/status-query flows, with dedicated error codes and structured logging. - Updates multiple connector option classes to surface timeout configuration via
ToConnectionSettings(), and adjusts telemetry unit tests for concurrency.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/Ratatosk.Testing/FakeTimeoutConnector.cs |
Adds a test utility connector that can simulate long-running operations for timeout tests. |
test/Ratatosk.Connectors.XUnit/Unit/ConnectorTelemetryTests.cs |
Makes Activity collection thread-safe and adds small waits to reduce timing flakiness. |
src/Ratatosk/ChannelConnectorBuilder.cs |
Adds fluent WithTimeout(...) to write timeout settings into connector configuration. |
src/Ratatosk.Twilio/TwilioWhatsAppOptions.cs |
Adds timeout properties and writes them into ConnectionSettings. |
src/Ratatosk.Twilio/TwilioSmsOptions.cs |
Adds timeout properties and writes them into ConnectionSettings. |
src/Ratatosk.Telegram/TelegramBotOptions.cs |
Adds timeout properties and writes them into ConnectionSettings. |
src/Ratatosk.Sendgrid/SendGridEmailOptions.cs |
Adds timeout properties and writes them into ConnectionSettings. |
src/Ratatosk.Firebase/FirebasePushOptions.cs |
Adds timeout properties and writes them into ConnectionSettings. |
src/Ratatosk.Facebook/FacebookMessengerOptions.cs |
Adds timeout properties and writes them into ConnectionSettings. |
src/Ratatosk.Connectors/LoggerExtensions.cs |
Adds structured timeout log messages for send/receive/status-query. |
src/Ratatosk.Connectors/ConnectorLoggerEventId.cs |
Adds new event IDs for timeout log messages. |
src/Ratatosk.Connectors/ConnectorErrorCodes.cs |
Adds new timeout-specific error codes with XML docs referencing timeout settings. |
src/Ratatosk.Connectors/ChannelConnectorBase.cs |
Core implementation: reads timeout settings, applies CTS-based timeouts, returns timeout error codes, and logs timeout events. |
src/Ratatosk.Connector.Abstractions/TimeoutSettingsKeys.cs |
Adds canonical connection parameter keys for timeout configuration. |
src/Ratatosk.Connector.Abstractions/TimeoutOptions.cs |
Adds a typed options model for timeout configuration (defaults + fluent setters). |
AGENTS.md |
Adds a repo agent guide with build/test commands and architecture/testing notes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
62
to
+66
| var telemetryOptions = ReadTelemetryFromSettings(); | ||
| _telemetry = new ConnectorTelemetry(Schema.ChannelType, ConnectorName, telemetryOptions); | ||
|
|
||
| _timeoutOptions = ReadTimeoutFromSettings(); | ||
| _effectiveTimeoutOptions = _timeoutOptions; |
Comment on lines
+233
to
+249
| if (ConnectionSettings.Parameters.TryGetValue(TimeoutSettingsKeys.SendTimeout, out var sendRaw) && sendRaw is string sendStr) | ||
| { | ||
| if (TimeSpan.TryParse(sendStr, out var sendTimeout)) | ||
| options.SendTimeout = sendTimeout; | ||
| } | ||
|
|
||
| if (ConnectionSettings.Parameters.TryGetValue(TimeoutSettingsKeys.ReceiveTimeout, out var receiveRaw) && receiveRaw is string receiveStr) | ||
| { | ||
| if (TimeSpan.TryParse(receiveStr, out var receiveTimeout)) | ||
| options.ReceiveTimeout = receiveTimeout; | ||
| } | ||
|
|
||
| if (ConnectionSettings.Parameters.TryGetValue(TimeoutSettingsKeys.StatusQueryTimeout, out var statusRaw) && statusRaw is string statusStr) | ||
| { | ||
| if (TimeSpan.TryParse(statusStr, out var statusTimeout)) | ||
| options.StatusQueryTimeout = statusTimeout; | ||
| } |
…guration and samples
Deploying ratatosk-docs with
|
| Latest commit: |
31e873a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://27e84d67.ratatosk-docs.pages.dev |
| Branch Preview URL: | https://29-connector-level-timeout-c.ratatosk-docs.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a comprehensive and configurable timeout policy for all connector operations in the Ratatosk messaging framework. It adds a new
TimeoutOptionsclass and integrates timeout handling into send, receive, and status query operations, ensuring that these operations are canceled if they exceed configurable durations. The implementation also provides error codes and logging for timeout scenarios, and allows retry policies to automatically include timeout errors if configured.The most important changes are:
Timeout Configuration and Constants
TimeoutOptionsclass toRatatosk.Connector.Abstractions, allowing fine-grained configuration of send, receive, and status query timeouts, as well as a flag to control retry behavior on timeouts. (TimeoutOptions.cs)TimeoutSettingsKeysfor consistent parameter key names when reading timeout settings from connector configuration. (TimeoutSettingsKeys.cs)Connector Base Enhancements
ChannelConnectorBaseto read timeout settings from connection parameters, expose virtual timeout getters (GetSendTimeout,GetReceiveTimeout,GetStatusQueryTimeout,ShouldRetryOnTimeout), and inject timeout logic into send, receive, and status query operations. Now, each operation is canceled and returns a specific error if it exceeds its configured timeout. (ChannelConnectorBase.cs) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Error Codes and Logging
ConnectorErrorCodes, with documentation linking them to the corresponding timeout options. (ConnectorErrorCodes.cs)ConnectorLoggerEventId. (ConnectorLoggerEventId.cs)Documentation
AGENTS.md, a high-level guide for the Ratatosk agent, including build/test commands, documentation site instructions, package dependency graph, architectural notes, and available skills. (AGENTS.md)