-
-
Notifications
You must be signed in to change notification settings - Fork 184
feat: Make transport channel capacity configurable #1040
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
911fd9d
d87061c
9c8f904
6f724ba
fbff3ea
94b2f8b
6d1c9ff
c819ce9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -26,12 +26,25 @@ pub struct TransportThread { | |||||
| } | ||||||
|
|
||||||
| impl TransportThread { | ||||||
| /// Spawn a new background thread. | ||||||
| pub fn new<SendFn>(mut send: SendFn) -> Self | ||||||
| /// Spawn a new background thread with the default channel capacity of 30. | ||||||
| pub fn new<SendFn>(send: SendFn) -> Self | ||||||
| where | ||||||
| SendFn: FnMut(Envelope, &mut RateLimiter) + Send + 'static, | ||||||
| { | ||||||
| let (sender, receiver) = sync_channel(30); | ||||||
| Self::with_capacity(send, 30) | ||||||
| } | ||||||
|
|
||||||
| /// Spawn a new background thread with a custom channel capacity. | ||||||
| /// | ||||||
| /// The channel capacity bounds how many envelopes may be queued before | ||||||
| /// `send` blocks. `channel_capacity` is clamped to a minimum of 1 to | ||||||
| /// avoid a rendezvous channel, which would silently drop envelopes under | ||||||
| /// `try_send`. | ||||||
| pub fn with_capacity<SendFn>(mut send: SendFn, channel_capacity: usize) -> Self | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. m: Let's make this
Suggested change
|
||||||
| where | ||||||
| SendFn: FnMut(Envelope, &mut RateLimiter) + Send + 'static, | ||||||
| { | ||||||
| let (sender, receiver) = sync_channel(channel_capacity.max(1)); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should honor I tested this end-to-end with the clamp removed and |
||||||
| let shutdown = Arc::new(AtomicBool::new(false)); | ||||||
| let shutdown_worker = shutdown.clone(); | ||||||
| let handle = thread::Builder::new() | ||||||
|
Comment on lines
+46
to
53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: With Suggested FixConsider using Prompt for AI AgentAlso affects:
|
||||||
|
|
||||||
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.
m: As we use the number
30as the default channel capacity in all the transports, we should extract it to a constant that we reuse in all of them.