Skip to content

feat: Introduce async handler model with RpcContext#155

Merged
doubleailes merged 1 commit into
mainfrom
introduce_async_handler
Apr 29, 2026
Merged

feat: Introduce async handler model with RpcContext#155
doubleailes merged 1 commit into
mainfrom
introduce_async_handler

Conversation

@doubleailes
Copy link
Copy Markdown
Owner

Replace the sync NamekoFunction = fn(&[Value]) -> GirolleResult<Value> with an async handler:

Arc<dyn Fn(RpcContext, Payload) -> BoxFuture<GirolleResult<Value>>
    + Send + Sync>

Every RPC delivery now builds an RpcContext carrying the routing key parts, correlation id, reply-to, inbound headers, and two capability handles (RpcCaller, EventDispatcher) that follow-up changes will wire to a shared in-service RPC core and an event publisher. In this change both capabilities are inert placeholders so handlers can be typed against them already.

The #[girolle] macro now generates an async wrapper, accepts both fn and async fn user functions, and detects an optional first ctx: RpcContext argument. Kwargs-to-args dispatch moved into the generated wrapper so RpcTask no longer needs an args list.

RpcTask::new and the removal of NamekoFunction are breaking; the hand-rolled examples/src/simple_service.rs is updated to the new shape.

Replace the sync `NamekoFunction = fn(&[Value]) -> GirolleResult<Value>`
with an async handler:

    Arc<dyn Fn(RpcContext, Payload) -> BoxFuture<GirolleResult<Value>>
        + Send + Sync>

Every RPC delivery now builds an `RpcContext` carrying the routing key
parts, correlation id, reply-to, inbound headers, and two capability
handles (`RpcCaller`, `EventDispatcher`) that follow-up changes will
wire to a shared in-service RPC core and an event publisher. In this
change both capabilities are inert placeholders so handlers can be
typed against them already.

The `#[girolle]` macro now generates an async wrapper, accepts both
`fn` and `async fn` user functions, and detects an optional first
`ctx: RpcContext` argument. Kwargs-to-args dispatch moved into the
generated wrapper so `RpcTask` no longer needs an `args` list.

`RpcTask::new` and the removal of `NamekoFunction` are breaking; the
hand-rolled `examples/src/simple_service.rs` is updated to the new
shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@doubleailes doubleailes merged commit 1314996 into main Apr 29, 2026
5 checks passed
@doubleailes doubleailes deleted the introduce_async_handler branch April 29, 2026 09:25
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