types

package
v1.26.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2018 License: MIT Imports: 13 Imported by: 0

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

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

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) ApplyProc

func (n *Name) ApplyProc(opts *api.ProcOpts)

ApplyProc implements ProcOption.

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

Handle implements transport.UnaryHandler#Handle.

func (*OrderedHandler) Start

func (h *OrderedHandler) Start(t testing.TB) error

Start implements Lifecycle.

func (*OrderedHandler) Stop

func (h *OrderedHandler) Stop(t testing.TB) error

Stop implements Lifecycle.

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

Handle implements transport.UnaryHandler.

func (*UnaryHandler) Start

func (h *UnaryHandler) Start(t testing.TB) error

Start implements Lifecycle.

func (*UnaryHandler) Stop

func (h *UnaryHandler) Stop(t testing.TB) error

Stop implements Lifecycle.

type WantHeader

type WantHeader struct {
	api.SafeTestingTBOnStart
	api.NoopStop

	Key   string
	Value string
}

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

Handle implements middleware.UnaryInbound.

Jump to

Keyboard shortcuts

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