teststub

package
v0.89.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	ReadLoopErrCh  chan error                // Chan from which tests read final read-loop errors.
	WriteLoopErrCh chan error                // Chan to which tests write final write-loop error (or nil).
	ReplReqCh      chan pb.ReplicateRequest  // Chan from which tests read ReplicateRequest.
	ReplRespCh     chan pb.ReplicateResponse // Chan to which tests write ReplicateResponse.
	ReadReqCh      chan pb.ReadRequest       // Chan from which tests read ReadRequest.
	ReadRespCh     chan pb.ReadResponse      // Chan to which tests write ReadResponse.
	AppendReqCh    chan pb.AppendRequest     // Chan from which tests read AppendRequest.
	AppendRespCh   chan pb.AppendResponse    // Chan to which tests write AppendResponse.

	ListFunc          func(context.Context, *pb.ListRequest) (*pb.ListResponse, error)           // List implementation.
	ApplyFunc         func(context.Context, *pb.ApplyRequest) (*pb.ApplyResponse, error)         // Apply implementation.
	ListFragmentsFunc func(context.Context, *pb.FragmentsRequest) (*pb.FragmentsResponse, error) // ListFragments implementation.
	// 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(t require.TestingT) *Broker

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

func (*Broker) Append

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

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

func (*Broker) Apply

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

Apply implements the JournalServer interface by proxying through ApplyFunc.

func (*Broker) Cleanup

func (b *Broker) Cleanup()

Cleanup cancels the Broker tasks.Group and asserts that it exits cleanly.

func (*Broker) Client

func (b *Broker) Client() pb.RoutedJournalClient

Client returns a RoutedJournalClient wrapping the GRPCLoopback.

func (*Broker) Endpoint

func (b *Broker) Endpoint() pb.Endpoint

Endpoint returns the server Endpoint.

func (*Broker) List

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

List implements the JournalServer interface by proxying through ListFunc.

func (*Broker) ListFragments

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

ListFragments implements the JournalServer interface by proxying through FragmentsFunc.

func (*Broker) Read

func (b *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 (b *Broker) Replicate(srv pb.Journal_ReplicateServer) error

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

Jump to

Keyboard shortcuts

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