teststub

package
v2.0.212+incompatible Latest Latest
Warning

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 8 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 {
	LoopbackServer
	Tasks *task.Group

	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)
	ListFragmentsFunc func(context.Context, *pb.FragmentsRequest) (*pb.FragmentsResponse, 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) ListFragments

func (p *Broker) ListFragments(ctx context.Context, req *pb.FragmentsRequest) (*pb.FragmentsResponse, error)

ListFragments implements the JournalServer interface by proxying through FragmentsFunc.

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 LoopbackServer

type LoopbackServer struct {
	*server.Server
	Conn *grpc.ClientConn
}

LoopbackServer serves a JournalServer over a loopback, for use within tests.

func NewLoopbackServer

func NewLoopbackServer(journalServer pb.JournalServer) LoopbackServer

NewLoopbackServer returns a LoopbackServer of the provided JournalServer.

func (LoopbackServer) MustClient

func (s LoopbackServer) MustClient() pb.JournalClient

MustClient returns a JournalClient of the test LoopbackServer.

func (LoopbackServer) QueueTasks

func (s LoopbackServer) QueueTasks(tasks *task.Group)

Jump to

Keyboard shortcuts

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