import "go.gazette.dev/core/broker/teststub"
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.
NewBroker returns a Broker instance served by a local gRPC server.
func (b *Broker) Append(srv pb.Journal_AppendServer) error
Append implements the JournalServer interface by proxying requests & responses through channels AppendReqCh & AppendRespCh.
func (b *Broker) Apply(ctx context.Context, req *pb.ApplyRequest) (*pb.ApplyResponse, error)
Apply implements the JournalServer interface by proxying through ApplyFunc.
Cleanup cancels the Broker tasks.Group and asserts that it exits cleanly.
func (b *Broker) Client() pb.RoutedJournalClient
Client returns a RoutedJournalClient wrapping the GRPCLoopback.
Endpoint returns the server Endpoint.
func (b *Broker) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, error)
List implements the JournalServer interface by proxying through ListFunc.
func (b *Broker) ListFragments(ctx context.Context, req *pb.FragmentsRequest) (*pb.FragmentsResponse, error)
ListFragments implements the JournalServer interface by proxying through FragmentsFunc.
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 (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.