Back to godoc.org
go.uber.org/yarpc / internal / testutils

Package testutils

v1.46.0
Latest Go to latest
Published: May 21, 2020 | License: MIT | Module: go.uber.org/yarpc

Index

Package Files

Variables

var (
	// AllTransportTypes are all TransportTypes,
	AllTransportTypes = []TransportType{
		TransportTypeHTTP,
		TransportTypeTChannel,
		TransportTypeGRPC,
	}
)

func NewClientDispatcher

func NewClientDispatcher(transportType TransportType, config *DispatcherConfig, logger *zap.Logger) (*yarpc.Dispatcher, error)

NewClientDispatcher returns a new client Dispatcher.

HTTP always will be configured as an outbound for Oneway. gRPC always will be configured as an outbound for Stream.

func NewServerDispatcher

func NewServerDispatcher(procedures []transport.Procedure, config *DispatcherConfig, logger *zap.Logger) (*yarpc.Dispatcher, error)

NewServerDispatcher returns a new server Dispatcher.

func WithClientInfo

func WithClientInfo(serviceName string, procedures []transport.Procedure, transportType TransportType, logger *zap.Logger, f func(*ClientInfo) error) (err error)

WithClientInfo wraps a function by setting up a client and server dispatcher and giving the function the client configuration to use in tests for the given TransportType.

The server dispatcher will be brought up using all TransportTypes and with the serviceName. The client dispatcher will be brought up using the given TransportType for Unary, HTTP for Oneway, and the serviceName with a "-client" suffix.

type ClientInfo

type ClientInfo struct {
	ClientConfig   transport.ClientConfig
	GRPCClientConn *ggrpc.ClientConn
	ContextWrapper *grpcctx.ContextWrapper
}

ClientInfo holds the client info for testing.

type DispatcherConfig

type DispatcherConfig struct {
	// contains filtered or unexported fields
}

DispatcherConfig is the configuration for a Dispatcher.

func NewDispatcherConfig

func NewDispatcherConfig(serviceName string) (*DispatcherConfig, error)

NewDispatcherConfig returns a new DispatcherConfig with assigned ports.

func (*DispatcherConfig) GetPort

func (d *DispatcherConfig) GetPort(transportType TransportType) (uint16, error)

GetPort gets the port for the TransportType.

func (*DispatcherConfig) GetServiceName

func (d *DispatcherConfig) GetServiceName() string

GetServiceName gets the service name.

type TransportType

type TransportType int

TransportType is a transport type.

const (
	// TransportTypeHTTP represents using HTTP.
	TransportTypeHTTP TransportType = iota
	// TransportTypeTChannel represents using TChannel.
	TransportTypeTChannel
	// TransportTypeGRPC represents using GRPC.
	TransportTypeGRPC
)

func ParseTransportType

func ParseTransportType(s string) (TransportType, error)

ParseTransportType parses a transport type from a string.

func (TransportType) String

func (t TransportType) String() string

String returns a string representation of t.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier