teststub

package
v2.0.100+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: MIT Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	Server

	ReplReqCh  chan *pb.ReplicateRequest
	ReplRespCh chan *pb.ReplicateResponse

	ReadReqCh  chan *pb.ReadRequest
	ReadRespCh chan *pb.ReadResponse

	AppendReqCh  chan *pb.AppendRequest
	AppendRespCh chan *pb.AppendResponse

	ListFunc  func(context.Context, *pb.ListRequest) (*pb.ListResponse, error)
	ApplyFunc func(context.Context, *pb.ApplyRequest) (*pb.ApplyResponse, error)

	ErrCh chan error
	// contains filtered or unexported fields
}

Broker stubs the read and write loops of broker RPCs, routing them onto channels which can be synchronously read and written within test bodies.

func NewBroker

func NewBroker(c *gc.C, ctx context.Context) *Broker

NewBroker returns a Broker instance served by a local GRPC server.

func (*Broker) Append

func (p *Broker) Append(srv pb.Journal_AppendServer) error

Append implements the JournalServer interface by proxying requests & responses through channels AppendReqCh & AppendRespCh.

func (*Broker) Apply

func (p *Broker) Apply(ctx context.Context, req *pb.ApplyRequest) (*pb.ApplyResponse, error)

Apply implements the JournalServer interface by proxying through ApplyFunc.

func (*Broker) List

func (p *Broker) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, error)

List implements the JournalServer interface by proxying through ListFunc.

func (*Broker) Read

func (p *Broker) Read(req *pb.ReadRequest, srv pb.Journal_ReadServer) error

Read implements the JournalServer interface by proxying requests & responses through channels ReadReqCh & ReadResponseCh.

func (*Broker) Replicate

func (p *Broker) Replicate(srv pb.Journal_ReplicateServer) error

Replicate implements the JournalServer interface by proxying requests & responses through channels ReplReqCh & ReplRespCh.

type Server

type Server struct {
	grpctest.Server
}

Server is a local gRPC server for use within tests.

func NewServer

func NewServer(ctx context.Context, journalServer pb.JournalServer) Server

NewServer returns a grpctest.Server of the provided JournalServer.

func (Server) MustClient

func (s Server) MustClient() pb.JournalClient

MustClient returns a JournalClient of the test Server.

Jump to

Keyboard shortcuts

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