Documentation
¶
Overview ¶
Package inproc provides an in-process client.Transport that dispatches RPCs synchronously into a frontend ZAP handler. It is the canonical seam for callers that live inside the same Go binary as the frontend (history's frontend self-dial, system workers, temporaltest, embedded boot tests). Compared to the loopback ZAP path it skips:
- the network listener bind on :9999
- the ZAP node start / discovery handshake
- the encode → frame → decode round trip
The Dispatcher interface is satisfied by *frontend.ZAPHandler. Tests can supply any opcode → handler shim that matches the same shape.
Wire compatibility with the network path is total: every opcode reaches the same handler function, so a workflow lifecycle exercised over inproc and one exercised over ZAP-on-loopback see identical server behavior. There is no semantic divergence and no opt-out flag.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrClosed = errors.New("hanzo/tasks/inproc: transport closed")
ErrClosed is returned when Call is invoked after Close.
Functions ¶
func NewClient ¶
NewClient constructs a client.Client backed by an in-process transport over dispatcher. opts.Transport must be nil — supplying both an explicit Transport and a Dispatcher is ambiguous and is rejected.
opts.HostPort is ignored for inproc (no dial happens). All other fields (Namespace, Identity, CallTimeout, ...) flow through to client.Dial unchanged.
Types ¶
type Dispatcher ¶
type Dispatcher interface {
// Dispatch invokes the handler registered for opcode synchronously
// and returns the response *zap.Message. Errors propagate raw.
Dispatch(ctx context.Context, opcode uint16, msg *zap.Message) (*zap.Message, error)
}
Dispatcher is the subset of *frontend.ZAPHandler that inproc.Transport requires. Keeping it small avoids a hard import cycle and lets tests inject lightweight fakes without standing up the real handler.
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements client.Transport by parsing the caller's frame, looking up the handler in the dispatcher, and emitting the returned message's bytes. Closed transports return ErrClosed for every subsequent Call.
func NewTransport ¶
func NewTransport(dispatcher Dispatcher) *Transport
NewTransport constructs a Transport that routes every Call through dispatcher. dispatcher must remain valid for the lifetime of the transport — Close on the transport does not Stop the dispatcher.
func (*Transport) Call ¶
Call satisfies client.Transport. It accepts the same frame layout the network transport produces (a complete ZAP frame) or a raw envelope body that needs wrapping. Either way it ends up calling the dispatcher with a parsed *zap.Message.
The returned bytes are an independent copy of the response frame, matching the network transport's contract that the response buffer does not alias internal state.