fakegrpc

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package fakegrpc provides a fake gRPC client/server for testing purpose.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamLoggerInterceptor added in v0.8.8

func StreamLoggerInterceptor(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamLoggerInterceptor intercepts streams to the server and logs the messages.

func UnaryLoggerInterceptor added in v0.8.8

func UnaryLoggerInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

UnaryLoggerInterceptor intercepts calls to the server and logs the request and response.

Types

type Fake

type Fake struct {
	Listener net.Listener
	Server   *grpc.Server
	Client   *grpc.ClientConn
}

Fake contains the server and client for a GRPC connection.

func New

func New() (*Fake, func() error)

New creates a gRPC client and server connected to eachother.

func (*Fake) Addr added in v0.8.8

func (f *Fake) Addr() string

Addr returns the address of the server.

func (*Fake) Start

func (f *Fake) Start()

Start starts the server. Must be called after registering the services on the server.

type LoggerStream added in v0.8.8

type LoggerStream struct {
	grpc.ServerStream
}

LoggerStream wraps around the embedded grpc.ServerStream, and intercepts the RecvMsg and SendMsg method call and logs them.

func (*LoggerStream) RecvMsg added in v0.8.8

func (w *LoggerStream) RecvMsg(m interface{}) error

RecvMsg recieves a message.

func (*LoggerStream) SendMsg added in v0.8.8

func (w *LoggerStream) SendMsg(m interface{}) error

SendMsg sends a message.

Jump to

Keyboard shortcuts

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