testutils

package
v1.32.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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.

Types

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.

Jump to

Keyboard shortcuts

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