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 ChooserFactory
- type GiveHeader
- type Name
- type OrderedHandler
- type Port
- type PortProvider
- type Procedure
- type RecvStreamMsg
- type SendStreamMsg
- 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 ChooserFactory ¶ added in v1.46.0
type ChooserFactory struct {
NewChooser func(peer.Identifier, peer.Transport) (peer.Chooser, error)
}
ChooserFactory is a concrete type that providers the peer chooser for the request.
func (*ChooserFactory) ApplyClientStreamRequest ¶ added in v1.46.0
func (n *ChooserFactory) ApplyClientStreamRequest(opts *api.ClientStreamRequestOpts)
ApplyClientStreamRequest implements api.ClientStreamRequestOption
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) ApplyClientStreamRequest ¶ added in v1.27.0
func (h *GiveHeader) ApplyClientStreamRequest(opts *api.ClientStreamRequestOpts)
ApplyClientStreamRequest implements api.ClientStreamRequestOption.
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 Listener net.Listener Port uint16 }
Port is an option injectable primitive for synchronizing port numbers between requests and services.
func (*Port) ApplyClientStreamRequest ¶ added in v1.27.0
func (n *Port) ApplyClientStreamRequest(opts *api.ClientStreamRequestOpts)
ApplyClientStreamRequest implements ClientStreamRequestOption
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) ApplyClientStreamRequest ¶ added in v1.27.0
func (n *Procedure) ApplyClientStreamRequest(opts *api.ClientStreamRequestOpts)
ApplyClientStreamRequest implements api.ClientStreamRequestOption
func (*Procedure) ApplyRequest ¶
func (n *Procedure) ApplyRequest(opts *api.RequestOpts)
ApplyRequest implements api.RequestOption
type RecvStreamMsg ¶ added in v1.27.0
type RecvStreamMsg struct { api.SafeTestingTBOnStart api.NoopStop WantBody []byte WantDecodeErrMsgs []string WantErrMsgs []string }
RecvStreamMsg is an action to receive a message from a stream. It can be applied to either a server or client stream.
func (*RecvStreamMsg) ApplyClientStream ¶ added in v1.27.0
func (s *RecvStreamMsg) ApplyClientStream(t testing.TB, c *transport.ClientStream)
ApplyClientStream implements ClientStreamAction
func (*RecvStreamMsg) ApplyServerStream ¶ added in v1.27.0
func (s *RecvStreamMsg) ApplyServerStream(c *transport.ServerStream) error
ApplyServerStream implements ServerStreamAction
type SendStreamMsg ¶ added in v1.27.0
type SendStreamMsg struct { api.SafeTestingTBOnStart api.NoopStop BodyFunc func() io.ReadCloser WantErrMsgs []string }
SendStreamMsg is an action to send a message to a stream. It can be applied to either a server or client stream.
func (*SendStreamMsg) ApplyClientStream ¶ added in v1.27.0
func (s *SendStreamMsg) ApplyClientStream(t testing.TB, c *transport.ClientStream)
ApplyClientStream implements ClientStreamAction
func (*SendStreamMsg) ApplyServerStream ¶ added in v1.27.0
func (s *SendStreamMsg) ApplyServerStream(c *transport.ServerStream) error
ApplyServerStream implements ServerStreamAction
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) ApplyClientStreamRequest ¶ added in v1.27.0
func (n *Service) ApplyClientStreamRequest(opts *api.ClientStreamRequestOpts)
ApplyClientStreamRequest implements api.ClientStreamRequestOption
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) ApplyClientStreamRequest ¶ added in v1.27.0
func (n *ShardKey) ApplyClientStreamRequest(opts *api.ClientStreamRequestOpts)
ApplyClientStreamRequest implements api.ClientStreamRequestOption
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) ApplyServerStream ¶ added in v1.27.0
func (h *WantHeader) ApplyServerStream(c *transport.ServerStream) error
ApplyServerStream implements ServerStreamAction.
func (*WantHeader) Handle ¶
func (h *WantHeader) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, handler transport.UnaryHandler) error
Handle implements middleware.UnaryInbound.