Documentation ¶
Overview ¶
Package api is for all interfaces and patterns that need to be implemented to interact with the yarpctest api, but not the explicit types we'll use to make requests, or the types that we'll use directly in tests.
The purpose of this sub-package is to reduce the information that needs to be provided at the top-level yarpctest package.
Index ¶
- func Run(name string, t testing.TB, f func(testing.TB))
- type Action
- type ActionFunc
- type ClientStreamAction
- type ClientStreamActionFunc
- type ClientStreamRequestOption
- type ClientStreamRequestOptionFunc
- type ClientStreamRequestOpts
- type HandlerOption
- type HandlerOptionFunc
- type HandlerOpts
- type Lifecycle
- type NoopLifecycle
- type NoopStop
- type ProcOption
- type ProcOpts
- type RequestOption
- type RequestOptionFunc
- type RequestOpts
- type SafeTestingTB
- type SafeTestingTBOnStart
- type ServerStreamAction
- type ServerStreamActionFunc
- type ServiceOption
- type ServiceOptionFunc
- type ServiceOpts
- type UnaryHandler
- type UnaryHandlerFunc
- type UnaryInboundMiddleware
- type UnaryInboundMiddlewareFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
Action defines an object that can be "Run" to assert things against the world through action.
type ActionFunc ¶
ActionFunc is a helper to convert a function to implement the Action interface
type ClientStreamAction ¶ added in v1.27.0
type ClientStreamAction interface {
ApplyClientStream(testing.TB, *transport.ClientStream)
}
ClientStreamAction is an action applied to a ClientStream.
type ClientStreamActionFunc ¶ added in v1.27.0
type ClientStreamActionFunc func(testing.TB, *transport.ClientStream)
ClientStreamActionFunc converts a function into a StreamAction.
func (ClientStreamActionFunc) ApplyClientStream ¶ added in v1.27.0
func (f ClientStreamActionFunc) ApplyClientStream(t testing.TB, c *transport.ClientStream)
ApplyClientStream implements ClientStreamAction.
type ClientStreamRequestOption ¶ added in v1.27.0
type ClientStreamRequestOption interface {
ApplyClientStreamRequest(*ClientStreamRequestOpts)
}
ClientStreamRequestOption can be used to configure a request.
type ClientStreamRequestOptionFunc ¶ added in v1.27.0
type ClientStreamRequestOptionFunc func(*ClientStreamRequestOpts)
ClientStreamRequestOptionFunc converts a function into a ClientStreamRequestOption.
func (ClientStreamRequestOptionFunc) ApplyClientStreamRequest ¶ added in v1.27.0
func (f ClientStreamRequestOptionFunc) ApplyClientStreamRequest(opts *ClientStreamRequestOpts)
ApplyClientStreamRequest implements ClientStreamRequestOption.
type ClientStreamRequestOpts ¶ added in v1.27.0
type ClientStreamRequestOpts struct { Port uint16 GiveRequest *transport.StreamRequest StreamActions []ClientStreamAction WantErrMsgs []string }
ClientStreamRequestOpts are configuration options for a yarpc stream request.
func NewClientStreamRequestOpts ¶ added in v1.27.0
func NewClientStreamRequestOpts() ClientStreamRequestOpts
NewClientStreamRequestOpts initializes a ClientStreamRequestOpts struct.
type HandlerOption ¶
type HandlerOption interface { Lifecycle ApplyHandler(opts *HandlerOpts) }
HandlerOption defines options that can be passed into a handler.
type HandlerOptionFunc ¶
type HandlerOptionFunc func(opts *HandlerOpts)
HandlerOptionFunc converts a function into a HandlerOption.
func (HandlerOptionFunc) ApplyHandler ¶
func (f HandlerOptionFunc) ApplyHandler(opts *HandlerOpts)
ApplyHandler implements HandlerOption.
type HandlerOpts ¶
type HandlerOpts struct {
Handlers []UnaryHandler
}
HandlerOpts are configuration options for a series of handlers.
type Lifecycle ¶
Lifecycle defines test infra that needs to be started before the actions and stopped afterwards.
type NoopLifecycle ¶
type NoopLifecycle struct{}
NoopLifecycle is a convenience struct that can be embedded to make a struct implement the Start and Stop methods of Lifecycle.
type NoopStop ¶
type NoopStop struct{}
NoopStop is a convenience struct that can be embedded to make a struct implement the Stop method of Lifecycle.
type ProcOption ¶
ProcOption defines the options that can be applied to a procedure.
type ProcOpts ¶
type ProcOpts struct { Name string HandlerSpec transport.HandlerSpec }
ProcOpts are configuration options for a procedure.
type RequestOption ¶
type RequestOption interface {
ApplyRequest(*RequestOpts)
}
RequestOption can be used to configure a request.
type RequestOptionFunc ¶
type RequestOptionFunc func(*RequestOpts)
RequestOptionFunc converts a function into a RequestOption.
func (RequestOptionFunc) ApplyRequest ¶
func (f RequestOptionFunc) ApplyRequest(opts *RequestOpts)
ApplyRequest implements RequestOption.
type RequestOpts ¶
type RequestOpts struct { Port uint16 UnaryMiddleware []middleware.UnaryOutbound GiveTimeout time.Duration GiveRequest *transport.Request WantResponse *transport.Response WantError error RetryCount int RetryInterval time.Duration }
RequestOpts are configuration options for a yarpc Request and assertions to make on the response.
func NewRequestOpts ¶
func NewRequestOpts() RequestOpts
NewRequestOpts initializes a RequestOpts struct.
type SafeTestingTB ¶
SafeTestingTB is a struct that wraps a testing.TB in a mutex for safe concurrent usage.
func (*SafeTestingTB) GetTestingTB ¶
func (s *SafeTestingTB) GetTestingTB() testing.TB
GetTestingTB safely gets the testing.TB for the testable.
func (*SafeTestingTB) SetTestingTB ¶
func (s *SafeTestingTB) SetTestingTB(t testing.TB)
SetTestingTB safely sets the testing.TB.
type SafeTestingTBOnStart ¶
type SafeTestingTBOnStart struct {
SafeTestingTB
}
SafeTestingTBOnStart is an embeddable struct that automatically grabs testing.TB objects on "Start" for lifecycles.
type ServerStreamAction ¶ added in v1.27.0
type ServerStreamAction interface { Lifecycle ApplyServerStream(*transport.ServerStream) error }
ServerStreamAction is an action applied to a ServerStream. If the action returns an error, that error will be used to end the ServerStream.
type ServerStreamActionFunc ¶ added in v1.27.0
type ServerStreamActionFunc func(*transport.ServerStream) error
ServerStreamActionFunc converts a function into a StreamAction.
func (ServerStreamActionFunc) ApplyServerStream ¶ added in v1.27.0
func (f ServerStreamActionFunc) ApplyServerStream(c *transport.ServerStream) error
ApplyServerStream implements ServerStreamAction.
type ServiceOption ¶
type ServiceOption interface { Lifecycle ApplyService(*ServiceOpts) }
ServiceOption is an option when creating a Service.
type ServiceOptionFunc ¶
type ServiceOptionFunc func(*ServiceOpts)
ServiceOptionFunc converts a function into a ServiceOption.
func (ServiceOptionFunc) ApplyService ¶
func (f ServiceOptionFunc) ApplyService(opts *ServiceOpts)
ApplyService implements ServiceOption.
type ServiceOpts ¶
type ServiceOpts struct { Name string Listener net.Listener Port uint16 Procedures []transport.Procedure }
ServiceOpts are the configuration options for a yarpc service.
type UnaryHandler ¶
type UnaryHandler interface { Lifecycle transport.UnaryHandler }
UnaryHandler is a wrapper around the transport.UnaryInbound and Lifecycle interfaces.
type UnaryHandlerFunc ¶
UnaryHandlerFunc converts a function into a transport.UnaryHandler.
func (UnaryHandlerFunc) Handle ¶
func (f UnaryHandlerFunc) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter) error
Handle implements yarpc/api/transport#UnaryHandler.
type UnaryInboundMiddleware ¶
type UnaryInboundMiddleware interface { Lifecycle middleware.UnaryInbound }
UnaryInboundMiddleware is a wrapper around the middleware.UnaryInbound and Lifecycle interfaces.
type UnaryInboundMiddlewareFunc ¶
type UnaryInboundMiddlewareFunc func(context.Context, *transport.Request, transport.ResponseWriter, transport.UnaryHandler) error
UnaryInboundMiddlewareFunc converts a function into a transport.UnaryInboundMiddleware.
func (UnaryInboundMiddlewareFunc) Handle ¶
func (f UnaryInboundMiddlewareFunc) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, h transport.UnaryHandler) error
Handle implements yarpc/api/transport#UnaryInboundMiddleware.