Skip to content

Adds Socketeer split API for concurrent send/receive#21

Merged
zheylmun merged 7 commits into
mainfrom
feature/split-stream-api
Jun 29, 2026
Merged

Adds Socketeer split API for concurrent send/receive#21
zheylmun merged 7 commits into
mainfrom
feature/split-stream-api

Conversation

@zheylmun

Copy link
Copy Markdown
Owner

This feature introduces the ability to split a Socketeer client into separate send (SocketeerTx) and receive (SocketeerRx) halves, enabling more flexible and concurrent usage patterns.

Summary

  • Adds 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.
  • Introduces SocketeerTx: The send half can be cloned to allow multiple tasks to send messages concurrently over the same WebSocket connection. It includes send (awaiting confirmation) and new send_unconfirmed methods for fire-and-forget message delivery, prioritizing throughput.
  • Introduces SocketeerRx: The receive half implements futures::Stream, providing an ergonomic way to consume incoming messages.
  • Adds SocketeerRx::reunite: Allows recombining SocketeerTx and SocketeerRx to restore the full Socketeer handle, complete with a ReuniteError for cases where mismatched halves are attempted to be reunited.
  • Socketeer implements futures::Stream: For direct consumption of messages when the client is not split.
  • Refactors internal socket loop communication to support optional send confirmations, which underpins the send_unconfirmed functionality.

Checklist

  • Adds new features
  • Introduces breaking changes
  • Addresses a bug
  • Improves performance
  • Enhances test coverage
  • Updates documentation
  • Release notes

zheylmun and others added 7 commits June 29, 2026 15:46
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

codecov Bot commented Jun 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.50000% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.14%. Comparing base (a40378b) to head (9f0aaab).

Files with missing lines Patch % Lines
src/split.rs 78.37% 16 Missing ⚠️
src/lib.rs 93.87% 3 Missing ⚠️
src/socket_loop.rs 97.29% 1 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zheylmun
zheylmun merged commit 1c3491a into main Jun 29, 2026
10 of 14 checks passed
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.

1 participant