Adds Socketeer split API for concurrent send/receive#21
Merged
Conversation
Adds Option<oneshot::Sender> so a future fire-and-forget send can skip the confirmation round-trip, plus shared take_terminal_error helpers. No behavior change; existing tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
SocketeerTx (Clone) with send/send_raw/close; SocketeerRx with next_message/next_raw_message. Adds Socketeer::from_parts and a shared send_confirmed helper. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Backpressure-respecting send that skips the confirmation round-trip; errors surface via the terminal error rather than per-send. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Yields Result<C::Rx, Error>; surfaces the real terminal cause once on abrupt close then ends, ends cleanly on graceful close, and continues past a per-message decode error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Recombines the split halves into a full Socketeer, validated via Arc::ptr_eq on the shared terminal-error slot; mismatched halves are returned in ReuniteError. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Lets the un-split handle be consumed with .next()/combinators, same disconnect semantics as SocketeerRx. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the sequential test_split_cloned_sender_concurrent with test_split_concurrent_sends_from_clones, which spawns two independent tokio tasks each owning a cloned SocketeerTx and asserts that both echoed payloads are received (order-insensitive via HashSet). Also exercises ReuniteError's Display and std::error::Error impls before the destructuring move in test_reunite_mismatch_returns_halves. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #21 +/- ##
==========================================
- Coverage 96.67% 94.14% -2.53%
==========================================
Files 6 7 +1
Lines 421 564 +143
==========================================
+ Hits 407 531 +124
- Misses 14 33 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 feature introduces the ability to split a
Socketeerclient into separate send (SocketeerTx) and receive (SocketeerRx) halves, enabling more flexible and concurrent usage patterns.Summary
Socketeer::split: Divides a connected client into a cloneable send half (SocketeerTx) and an owned receive half (SocketeerRx). This allows for managing send and receive logic in separate, independent tasks.SocketeerTx: The send half can be cloned to allow multiple tasks to send messages concurrently over the same WebSocket connection. It includessend(awaiting confirmation) and newsend_unconfirmedmethods for fire-and-forget message delivery, prioritizing throughput.SocketeerRx: The receive half implementsfutures::Stream, providing an ergonomic way to consume incoming messages.SocketeerRx::reunite: Allows recombiningSocketeerTxandSocketeerRxto restore the fullSocketeerhandle, complete with aReuniteErrorfor cases where mismatched halves are attempted to be reunited.Socketeerimplementsfutures::Stream: For direct consumption of messages when the client is not split.send_unconfirmedfunctionality.Checklist