Skip to content

Move remote request handling into core behind the remote-adapter feature flag #774

Open

Description

@LiamCarPer

Part of #727.

Move the duplicated remote-request handling from the redis, postgres and mongodb
adapters into socketioxide_core behind the existing remote-adapter feature flag.

Current state: each adapter implements a near-identical recv_req dispatch plus the
same recv_* handlers (~110 LOC per adapter): broadcast, broadcast_with_ack,
disconnect_sockets, all_rooms, add/del sockets, fetch sockets. Each also repeats the
same get_res / broadcast_with_ack skeleton (response channel setup,
ResponseHandlers insert, ResponseTypeId filter, take(remote_serv_cnt), request
timeout).

Proposed shared API (sketch, in core):

Each adapter then keeps only its wire-specific parts (codec, driver calls,
channel/item routing). No behavior or wire-format change.

Activity

  1. LiamCarPer commented on Aug 23, 2026

    @LiamCarPer
    ContributorAuthor

    Hey, here is what i was thinking for this PR:

    A shared trait in core (RemoteRequestHandler<E> behind remote-adapter) with default implementations of the recv_req dispatch plus all 7 recv_* handlers (~150 LOC once instead of 3 times). Each adapter only implements local() (the CoreLocalAdapter, which covers everything the handlers use, including uid/ns/ack_timeout for the logs), send_res and an overridable recv_heartbeat hook (no-op by default, postgres and mongodb delegate to the HeartbeatSender logic from #768). Redis keeps a tiny decode-and-delegate wrapper, postgres and mongodb just delete their copies.

    A small response-wait helper covering the identical get_res tail (channel sizing + ResponseHandlers insert + ResponseTypeId filter + take(serv_cnt) + timeout) and wrapping uniformly in DropStream. Btw this also fixes a leak: postgres is the only adapter whose get_res doesn't wrap in DropStream, so its rooms/fetch handler entries pile up in the map forever. Happy to split that fix into its own commit if you prefer.

    Some normalizations (tiny differences, picked on purpose):

    • send_res unified to (req_id, req_origin) arg order plus the strictest bounds (T: Serialize + Debug + Send + 'static, future + Send + 'static), redis's inverted order is handled inside its impl
    • missing opts on a request: warn and skip everywhere (redis already does, postgres and mongodb silently drop it right now)
    • loopback self-check moved inside the shared dispatch (redis had it there, postgres and mongodb filter earlier so it's a no-op for them)
    • logs normalized to one style

    Deferred to the codec PR: sharing the outbound broadcast_with_ack body, it needs associated types for the raw response item + decoder which belong with the codec work.

    One thing i noticed while i was in there, not touched by this PR: redis's broadcast_with_ack passes opts.server_id as the send target but always uses server_count - 1 as the expected ack count, so a targeted broadcast's ack stream completes by timeout instead of cleanly. Flagging it in case you want a separate issue for it.

  2. Totodore commented on Aug 29, 2026

    @Totodore
    Owner

    Seems good to me, please make a separate PR redis bug fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-coreArea related to socketioxide-core

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions