Skip to content

Response typing

Declare Request<R> on a query or command to state what its caller should receive. The compiler can then infer its result type, so callers need no casts.

public record GetGreeting(String name) implements Request<String> {
@HandleQuery
String handle() { return "Hello, " + name + "!"; }
}
String greeting = Fluxzero.queryAndWait(new GetGreeting("Alice"));

The example keeps the handler on the query. Separate handlers can use the same request contract.

The fixture also knows the result type:

TestFixture.create().whenQuery(new GetGreeting("Alice"))
.expectResult(greeting -> greeting.startsWith("Hello"));

The SDK’s annotation processor checks the return types of annotated handlers against the request contract. Request<R> describes the response type; it does not register or create a handler. See message handling for handler registration and asynchronous results.


© 2026 Fluxzero