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) Fragments(ctx context.Context, req *pb.FragmentsRequest) (*pb.FragmentsResponse, error)
- func (p *Broker) List(ctx context.Context, req *pb.ListRequest) (*pb.ListResponse, 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 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) FragmentsFunc 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) Fragments ¶
func (p *Broker) Fragments(ctx context.Context, req *pb.FragmentsRequest) (*pb.FragmentsResponse, error)
Fragments implements the JournalServer interface by proxying through FragmentsFunc.
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) 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(ctx context.Context, 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.