core: go.gazette.dev/core/broker/teststub Index | Files

package teststub

import "go.gazette.dev/core/broker/teststub"

Index

Package Files

broker.go

type Broker Uses

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 Uses

func NewBroker(t require.TestingT) *Broker

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

func (*Broker) Append Uses

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 Uses

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 Uses

func (b *Broker) Cleanup()

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

func (*Broker) Client Uses

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

Client returns a RoutedJournalClient wrapping the GRPCLoopback.

func (*Broker) Endpoint Uses

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

Endpoint returns the server Endpoint.

func (*Broker) List Uses

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 Uses

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 Uses

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 Uses

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

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

Package teststub imports 8 packages (graph). Updated 2020-07-11. Refresh now. Tools for package owners.