07 / ROUTING
interceptor
One shape for both halves of the wire: an invoker turns a call into a result, an interceptor wraps an invoker, and the transport is the innermost one.
WHERE IT SITS
INTERFACE
struct CallstructOne unary call: its gRPC path (/package.Service/Method) and the request message's wire bytes.
fn Call::name(self : Call) -> StringfnThe value the name of the method is not: method is reserved in MoonBit, and the path already carries the service and the name.
type Invoker = (Call) -> Result[Bytes, @moonrpc.Status] raisetypeThe innermost of a chain: makes the call.
type Interceptor = (Invoker) -> InvokertypeOne layer around an invoker.
fn chain(interceptors : Array[Interceptor], base : Invoker) -> InvokerfnFold interceptors around base, first in the array outermost — the order ChainUnaryInterceptor gives them.
fn internal_status() -> @moonrpc.StatusfnThe grpc-status an error becomes when a layer cannot say anything better. The transport's own failures are internal: the caller asked for a method, not for a protocol exchange.