Skip to content

feat: @timeout_ms codegen — Client::call_with_timeout - #5

Merged
Kinflou merged 1 commit into
mainfrom
feat/timeout-codegen
Sep 1, 2026
Merged

feat: @timeout_ms codegen — Client::call_with_timeout#5
Kinflou merged 1 commit into
mainfrom
feat/timeout-codegen

Conversation

@Kinflou

@Kinflou Kinflou commented Sep 1, 2026

Copy link
Copy Markdown
Member

The codegen half of per-call settings, pairing with runtime#7.

protocol Api {
    @timeout_ms = 5000
    function slow(q: str) -> Reply;
}

→ the generated client method:

pub fn slow(&mut self, q: &str) -> Result<Reply, CallError<ApiSlowError>> {
    let (reply, fmt) = self.0.call_with_timeout(
        0u16, &ApiSlowParams { q }, core::time::Duration::from_millis(5000),
    )?;
    // ...
}

No annotation → self.0.call(...) as before. One-way functions ignore it (nothing to wait for). Only the client stub changes — trait, dispatcher, params struct untouched.

@timeout_ms is read from Function.parameters (a Property { name: "timeout_ms", expression }, frozen from the function annotation — core#46). An unparseable value is ignored (falls back to call).

Bumps the generated crate's comline-runtime pin to the rev with call_with_timeout.

Tests

tests/generate.rs@timeout_ms = 2500 emits call_with_timeout(.., from_millis(2500)), an unannotated sibling stays on call. tests/compiles.rs gains an await_ack fn with @timeout_ms = 3000 so the compile-against-comline-runtime check exercises it. 7 string tests + 1 compile test green.

That closes the "deepen the generator" trio (borrowed args · one-way · per-call settings).

A `@timeout_ms = N` annotation on a request/response `function` (frozen
into `Function.parameters` as a `Property`) now makes the generated client
method call `Client::call_with_timeout(i, &params,
core::time::Duration::from_millis(N))` instead of `call`. No annotation ->
`call` as before. One-way functions ignore it (nothing to wait for).

Only the client stub changes; the trait, dispatcher and params struct are
untouched. Bumps the generated crate's `comline-runtime` pin to the rev
with `call_with_timeout` (runtime#7).

tests/generate.rs: `@timeout_ms = 2500` -> `call_with_timeout(..from_millis(2500))`,
an unannotated sibling stays on `call`. tests/compiles.rs gains an
`await_ack` fn with `@timeout_ms = 3000` so the compile-against-runtime
check exercises the new path.
@Kinflou
Kinflou merged commit 71101c8 into main Sep 1, 2026
2 checks passed
@Kinflou
Kinflou deleted the feat/timeout-codegen branch September 2, 2026 07:20
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