testsvc

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: MIT Imports: 15 Imported by: 0

README

Test Service

This directory contains a service used by the metrics and tracing tests. This code is not intended to be used outside of this repo.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields test.Fields

Shadow generated type to avoid dependency creep.

type GRPCOption

type GRPCOption func(*grpcOptions)

GRPCOption is a function that can be used to configure the gRPC server.

func WithDialOptions

func WithDialOptions(opts ...grpc.DialOption) GRPCOption

WithDialOptions configures the gRPC client.

func WithServerOptions

func WithServerOptions(opts ...grpc.ServerOption) GRPCOption

WithServerOptions configures the gRPC server.

func WithStreamFunc

func WithStreamFunc(fn StreamFunc) GRPCOption

WithStreamFunc provides the implementation for the gRPC streaming method.

func WithUnaryFunc

func WithUnaryFunc(fn UnaryFunc) GRPCOption

WithUnaryFunc provides the implementation for the gRPC unary method.

type GRPClient

type GRPClient interface {
	GRPCMethod(context.Context, *Fields) (*Fields, error)
	GRPCStream(context.Context) (Stream, error)
}

GRPClient is a test service gRPC client.

func SetupGRPC

func SetupGRPC(t *testing.T, opts ...GRPCOption) (c GRPClient, stop func())

SetupGRPC instantiates the test service with the given options and starts a gRPC server to host it. The results are a ready-to-use client and a function used to stop the server.

type HTTPClient

type HTTPClient interface {
	HTTPMethod(ctx context.Context, req *Fields) (res *Fields, err error)
}

HTTPClient is a test service HTTP client.

func SetupHTTP

func SetupHTTP(t *testing.T, opts ...HTTPOption) (c HTTPClient, stop func())

SetupHTTP instantiates the test gRPC service with the given options. It returns a ready-to-use client and a function used to stop the server.

type HTTPOption

type HTTPOption func(*httpOptions)

HTTPOption is a function that can be used to configure the HTTP server.

func WithHTTPFunc

func WithHTTPFunc(fn UnaryFunc) HTTPOption

func WithHTTPMiddleware

func WithHTTPMiddleware(fn ...func(http.Handler) http.Handler) HTTPOption

type Service added in v0.15.0

type Service struct {
	HTTPFunc   UnaryFunc
	GRPCFunc   UnaryFunc
	StreamFunc StreamFunc
}

func (*Service) GrpcMethod added in v0.15.0

func (s *Service) GrpcMethod(ctx context.Context, req *test.Fields) (res *test.Fields, err error)

func (*Service) GrpcStream added in v0.15.0

func (s *Service) GrpcStream(ctx context.Context, stream test.GrpcStreamServerStream) (err error)

func (*Service) HTTPMethod added in v0.15.0

func (s *Service) HTTPMethod(ctx context.Context, req *test.Fields) (res *test.Fields, err error)

type Stream

type Stream interface {
	Send(*Fields) error
	Recv() (*Fields, error)
	Close() error
}

type StreamFunc

type StreamFunc func(context.Context, Stream) (err error)

type UnaryFunc

type UnaryFunc func(context.Context, *Fields) (res *Fields, err error)

Jump to

Keyboard shortcuts

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