Documentation
¶
Overview ¶
Package echo is a self-contained demo of zapgen interface (RPC) codegen.
echo.zap declares two structs (Ping, Pong) and an Echo service with four methods covering every shape: request+response, request-only (void return), response-only (no request), and bare (no params). The *_zap.go files are generated by zapgen and checked in; echo_test.go drives the generated EchoClient through DispatchEcho against a hand-written EchoHandler over an in-memory channel, proving the ordinal-routed call envelope round-trips.
Index ¶
- Constants
- func DispatchEcho(h EchoHandler, envelope []byte) ([]byte, error)
- func NewPing(in PingInput) []byte
- func NewPong(in PongInput) []byte
- type EchoChannel
- type EchoClient
- func (c *EchoClient) Health() (rpc.Promise, []byte, error)
- func (c *EchoClient) HealthOn(on rpc.Promise) (rpc.Promise, []byte, error)
- func (c *EchoClient) Notify(req []byte) (rpc.Promise, error)
- func (c *EchoClient) NotifyOn(on rpc.Promise) (rpc.Promise, error)
- func (c *EchoClient) Ping(req []byte) (rpc.Promise, []byte, error)
- func (c *EchoClient) PingOn(on rpc.Promise) (rpc.Promise, []byte, error)
- func (c *EchoClient) Shutdown() (rpc.Promise, error)
- func (c *EchoClient) ShutdownOn(on rpc.Promise) (rpc.Promise, error)
- type EchoHandler
- type Ping
- type PingInput
- type Pong
- type PongInput
Constants ¶
const ( EchoPingOrdinal uint32 = 1 EchoNotifyOrdinal uint32 = 2 EchoHealthOrdinal uint32 = 3 EchoShutdownOrdinal uint32 = 4 )
Method ordinals for the Echo service (stable 1-based wire ids).
Variables ¶
This section is empty.
Functions ¶
func DispatchEcho ¶
func DispatchEcho(h EchoHandler, envelope []byte) ([]byte, error)
DispatchEcho decodes a Call envelope, routes it by method ordinal to h, and returns the response envelope. An unknown ordinal yields a StatusNotFound response; a handler error yields StatusInternal.
Types ¶
type EchoChannel ¶
EchoChannel ships one Call envelope and awaits its correlated Response.
type EchoClient ¶
type EchoClient struct {
// contains filtered or unexported fields
}
EchoClient is a typed RPC client for the Echo service over a ZAP call channel. Each call takes a fresh PromiseID from sess; the pipelined "On" form of a method sets Target to a prior call's Promise so the server chains them.
func NewEchoClient ¶
func NewEchoClient(ch EchoChannel, capability []byte) *EchoClient
NewEchoClient returns a client that issues calls over ch, attaching cap (which may be nil) to every request.
func (*EchoClient) HealthOn ¶ added in v1.4.0
HealthOn issues Health as a dependent call pipelined on the answer of on: the server substitutes on's resolved result for this call's payload before dispatch, so it ships without waiting for on to round-trip.
func (*EchoClient) NotifyOn ¶ added in v1.4.0
NotifyOn issues Notify as a dependent call pipelined on the answer of on: the server substitutes on's resolved result for this call's payload before dispatch, so it ships without waiting for on to round-trip.
func (*EchoClient) PingOn ¶ added in v1.4.0
PingOn issues Ping as a dependent call pipelined on the answer of on: the server substitutes on's resolved result for this call's payload before dispatch, so it ships without waiting for on to round-trip.
func (*EchoClient) ShutdownOn ¶ added in v1.4.0
ShutdownOn issues Shutdown as a dependent call pipelined on the answer of on: the server substitutes on's resolved result for this call's payload before dispatch, so it ships without waiting for on to round-trip.
type EchoHandler ¶
type EchoHandler interface {
Ping(req []byte) ([]byte, error)
Notify(req []byte) error
Health() ([]byte, error)
Shutdown() error
}
EchoHandler is the server contract for the Echo service. Implement each method, then route requests to it with DispatchEcho.
type Ping ¶
type Ping struct {
// contains filtered or unexported fields
}
Ping is a zero-copy view into a ZAP-encoded Ping message.
type PingInput ¶
type PingInput struct {
Seq uint64
}
PingInput collects the field values for NewPing.