Documentation ¶
Index ¶
- type Broker
- func (p *Broker) Append(srv pb.Journal_AppendServer) error
- func (p *Broker) Apply(ctx context.Context, req *pb.ApplyRequest) (*pb.ApplyResponse, error)
- func (p *Broker) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, error)
- func (p *Broker) ListFragments(ctx context.Context, req *pb.FragmentsRequest) (*pb.FragmentsResponse, error)
- func (p *Broker) Read(req *pb.ReadRequest, srv pb.Journal_ReadServer) error
- func (p *Broker) Replicate(srv pb.Journal_ReplicateServer) error
- type LoopbackServer
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 (*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.
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)