Documentation ¶
Overview ¶
Package types are for objects in the yarpctest API that implement multiple interfaces. So if we want to reuse a function like "Name" across the Service and Procedure option patterns, we need to have specific structs that implement both of those types. These structs also need to be public. By putting these structs into a single package, we can remove unusable functions from the exposed yarpctest package and hide them in a sub package.
Index ¶
- type GiveHeader
- type Name
- type OrderedHandler
- type Port
- type PortProvider
- type Procedure
- type Service
- type ShardKey
- type UnaryHandler
- func (h *UnaryHandler) ApplyHandler(opts *api.HandlerOpts)
- func (h *UnaryHandler) ApplyProc(opts *api.ProcOpts)
- func (h *UnaryHandler) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter) error
- func (h *UnaryHandler) Start(t testing.TB) error
- func (h *UnaryHandler) Stop(t testing.TB) error
- type WantHeader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GiveHeader ¶
type GiveHeader struct { api.NoopLifecycle Key string Value string }
GiveHeader is an API for giving headers to a Request or a Response.
func (*GiveHeader) ApplyRequest ¶
func (h *GiveHeader) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements RequestOption.
func (*GiveHeader) Handle ¶
func (h *GiveHeader) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, handler transport.UnaryHandler) error
Handle implements middleware.UnaryInbound.
type Name ¶
type Name struct { api.NoopLifecycle Name string }
Name is a concrete type that implements both ServiceOption and ProcedureOption interfaces so it can be used interchangeably.
func (*Name) ApplyService ¶
func (n *Name) ApplyService(opts *api.ServiceOpts)
ApplyService implements ServiceOption.
type OrderedHandler ¶
type OrderedHandler struct { Handlers []api.UnaryHandler // contains filtered or unexported fields }
OrderedHandler implements the transport.UnaryHandler and ProcOption interfaces.
func (*OrderedHandler) ApplyProc ¶
func (h *OrderedHandler) ApplyProc(opts *api.ProcOpts)
ApplyProc implements ProcOption.
func (*OrderedHandler) Handle ¶
func (h *OrderedHandler) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter) error
Handle implements transport.UnaryHandler#Handle.
type Port ¶
type Port struct { api.NoopLifecycle Port uint16 // contains filtered or unexported fields }
Port is an option injectable primitive for synchronizing port numbers between requests and services.
func (*Port) ApplyRequest ¶
func (n *Port) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements api.RequestOption
func (*Port) ApplyService ¶
func (n *Port) ApplyService(opts *api.ServiceOpts)
ApplyService implements api.ServiceOption.
type PortProvider ¶
type PortProvider struct {
// contains filtered or unexported fields
}
PortProvider maintains a list of IDs to Ports.
func NewPortProvider ¶
func NewPortProvider(t testing.TB) *PortProvider
NewPortProvider creates an object that can be used to synchronize ports in yarpctest infrastructure. Ports can be acquired through the "Port" function which will create new ports for the test based on the id passed into the function.
func (*PortProvider) NamedPort ¶
func (p *PortProvider) NamedPort(id string) *Port
NamedPort will return a *Port object that exists for the passed in 'id', or it will create a *Port object if one does not already exist.
type Procedure ¶
type Procedure struct {
Procedure string
}
Procedure is a concrete type that represents the "procedure" for a request. It can be used in multiple interfaces.
func (*Procedure) ApplyRequest ¶
func (n *Procedure) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements api.RequestOption
type Service ¶
type Service struct {
Service string
}
Service is a concrete type that represents the "service" for a request. It can be used in multiple interfaces.
func (*Service) ApplyRequest ¶
func (n *Service) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements api.RequestOption
type ShardKey ¶
type ShardKey struct {
ShardKey string
}
ShardKey is a concrete type that represents the "shard key" for a request. It can be used in multiple interfaces.
func (*ShardKey) ApplyRequest ¶
func (n *ShardKey) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements api.RequestOption
type UnaryHandler ¶
type UnaryHandler struct { Handler api.UnaryHandler Middleware []api.UnaryInboundMiddleware }
UnaryHandler is a struct that implements the ProcOptions and HandlerOption interfaces (so it can be used directly as a procedure, or as a single use handler (depending on the use case)).
func (*UnaryHandler) ApplyHandler ¶
func (h *UnaryHandler) ApplyHandler(opts *api.HandlerOpts)
ApplyHandler implements HandlerOption.
func (*UnaryHandler) ApplyProc ¶
func (h *UnaryHandler) ApplyProc(opts *api.ProcOpts)
ApplyProc implements ProcOption.
func (*UnaryHandler) Handle ¶
func (h *UnaryHandler) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter) error
Handle implements transport.UnaryHandler.
type WantHeader ¶
WantHeader is an API for asserting headers sent on a Request or a Response.
func (*WantHeader) ApplyRequest ¶
func (h *WantHeader) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements RequestOption.
func (*WantHeader) Handle ¶
func (h *WantHeader) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, handler transport.UnaryHandler) error
Handle implements middleware.UnaryInbound.