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) Read(req *pb.ReadRequest, srv pb.Journal_ReadServer) error
- func (p *Broker) Replicate(srv pb.Journal_ReplicateServer) error
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Broker ¶
type Broker struct { Server 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) 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) 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 Server ¶
Server is a local gRPC server for use within tests.
func NewServer ¶
func NewServer(ctx context.Context, journalServer pb.JournalServer) Server
NewServer returns a grpctest.Server of the provided JournalServer.
func (Server) MustClient ¶
func (s Server) MustClient() pb.JournalClient
MustClient returns a JournalClient of the test Server.