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"));data class GetGreeting(val name: String) : Request<String> { @HandleQuery fun handle() = "Hello, $name!"}
val greeting = Fluxzero.queryAndWait(GetGreeting("Alice"))The example keeps the handler on the query. Separate handlers can use the same request contract.
Typed tests
Section titled “Typed tests”The fixture also knows the result type:
TestFixture.create().whenQuery(new GetGreeting("Alice")) .expectResult(greeting -> greeting.startsWith("Hello"));TestFixture.create().whenQuery(GetGreeting("Alice")) .expectResult { greeting: String -> greeting.startsWith("Hello") }Handler compatibility
Section titled “Handler compatibility”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