api

package
v1.27.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2018 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(name string, t testing.TB, f func(testing.TB))

Run will cast the testing.TB to it's sub and call the appropriate Run func.

Types

type Action

type Action interface {
	Run(testing.TB)
}

Action defines an object that can be "Run" to assert things against the world through action.

type ActionFunc

type ActionFunc func(testing.TB)

ActionFunc is a helper to convert a function to implement the Action interface

func (ActionFunc) Run

func (f ActionFunc) Run(t testing.TB)

Run implement Action.

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

type Lifecycle interface {
	Start(testing.TB) error
	Stop(testing.TB) error
}

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.

func (*NoopLifecycle) Start

func (b *NoopLifecycle) Start(t testing.TB) error

Start is a Noop.

func (*NoopLifecycle) Stop

func (b *NoopLifecycle) Stop(t testing.TB) error

Stop is a Noop.

type NoopStop

type NoopStop struct{}

NoopStop is a convenience struct that can be embedded to make a struct implement the Stop method of Lifecycle.

func (*NoopStop) Stop

func (b *NoopStop) Stop(t testing.TB) error

Stop is a Noop.

type ProcOption

type ProcOption interface {
	Lifecycle

	ApplyProc(*ProcOpts)
}

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
	GiveTimeout  time.Duration
	GiveRequest  *transport.Request
	WantResponse *transport.Response
	WantError    error
}

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

type SafeTestingTB struct {
	sync.Mutex
	// contains filtered or unexported fields
}

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.

func (*SafeTestingTBOnStart) Start

func (s *SafeTestingTBOnStart) Start(t testing.TB) error

Start safely sets the testing.TB for the testable.

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.

func (ServerStreamActionFunc) Start added in v1.27.0

Start is a noop for wrapped functions

func (ServerStreamActionFunc) Stop added in v1.27.0

Stop is a noop for wrapped functions

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.

func (ServiceOptionFunc) Start

func (f ServiceOptionFunc) Start(testing.TB) error

Start is a noop for wrapped functions

func (ServiceOptionFunc) Stop

Stop is a noop for wrapped functions

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

type UnaryHandlerFunc func(context.Context, *transport.Request, transport.ResponseWriter) error

UnaryHandlerFunc converts a function into a transport.UnaryHandler.

func (UnaryHandlerFunc) Handle

Handle implements yarpc/api/transport#UnaryHandler.

func (UnaryHandlerFunc) Start

func (f UnaryHandlerFunc) Start(testing.TB) error

Start is a noop for wrapped functions.

func (UnaryHandlerFunc) Stop

func (f UnaryHandlerFunc) Stop(testing.TB) error

Stop is a noop for wrapped functions.

type UnaryInboundMiddleware

type UnaryInboundMiddleware interface {
	Lifecycle

	middleware.UnaryInbound
}

UnaryInboundMiddleware is a wrapper around the middleware.UnaryInbound and Lifecycle interfaces.

type UnaryInboundMiddlewareFunc

UnaryInboundMiddlewareFunc converts a function into a transport.UnaryInboundMiddleware.

func (UnaryInboundMiddlewareFunc) Handle

Handle implements yarpc/api/transport#UnaryInboundMiddleware.

func (UnaryInboundMiddlewareFunc) Start

Start is a noop for wrapped functions.

func (UnaryInboundMiddlewareFunc) Stop

Stop is a noop for wrapped functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL