moonzero · control plane v0.15.0 · 49 packages · 4 targets · Apache-2.0 docs / routing / interceptor GitHub

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.

struct Call

structOne unary call: its gRPC path (/package.Service/Method) and the request message's wire bytes.

fn Call::name(self : Call) -> String

fnThe 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] raise

typeThe innermost of a chain: makes the call.

type Interceptor = (Invoker) -> Invoker

typeOne layer around an invoker.

fn chain(interceptors : Array[Interceptor], base : Invoker) -> Invoker

fnFold interceptors around base, first in the array outermost — the order ChainUnaryInterceptor gives them.

fn internal_status() -> @moonrpc.Status

fnThe 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.