Documentation
¶
Index ¶
- func Generate(config *TemplateConfig)
- func HandleRequest[R any](ss *GRPCServerStub, ctx context.Context, rpcName string, req any) (R, error)
- type GRPCServer
- type GRPCServerStub
- func (ss *GRPCServerStub) ClearAllResponses(tid string)
- func (ss *GRPCServerStub) HandleRequest(ctx context.Context, rpcName string, req any) (any, error)
- func (ss *GRPCServerStub) SetResponse(tid, rpcName string, response any, err error)
- func (ss *GRPCServerStub) SetResponseCreator(tid, rpcName string, creator ResponseCreator)
- type RPCMethod
- type RequestCapture
- type ResponseBuilder
- type ResponseCreator
- type TemplateConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(config *TemplateConfig)
Generate generates a fake server code to stdout.
func HandleRequest ¶
func HandleRequest[R any]( ss *GRPCServerStub, ctx context.Context, rpcName string, req any, ) (R, error)
HandleRequest is a generic function to handle requests.
Types ¶
type GRPCServer ¶
type GRPCServer struct {
// contains filtered or unexported fields
}
GRPCServer provides a gRPC server.
func NewGRPCServer ¶
func NewGRPCServer() *GRPCServer
NewGRPCServer() assigns a new port and creates a gRPC server.
func (*GRPCServer) Addr ¶
func (gs *GRPCServer) Addr() string
Addr returns the address with a port number.
func (*GRPCServer) Port ¶
func (gs *GRPCServer) Port() string
Port returns the port number of the address.
func (*GRPCServer) Server ¶
func (gs *GRPCServer) Server() *grpc.Server
Server returns a grpcServer.
type GRPCServerStub ¶
type GRPCServerStub struct {
// contains filtered or unexported fields
}
GRPCServerStub provides basic primitives for a fake gRPC server.
func (*GRPCServerStub) ClearAllResponses ¶
func (ss *GRPCServerStub) ClearAllResponses( tid string, )
ClearAllResponses clear all responsed and errors for tid.
func (*GRPCServerStub) HandleRequest ¶
func (ss *GRPCServerStub) HandleRequest( ctx context.Context, rpcName string, req any, ) (any, error)
HandleRequest is a method to handle requestes.
func (*GRPCServerStub) SetResponse ¶
func (ss *GRPCServerStub) SetResponse( tid, rpcName string, response any, err error, )
SetResponse sets specified response and error for a RPC(rcpName). tid represents Testing ID.
func (*GRPCServerStub) SetResponseCreator ¶
func (ss *GRPCServerStub) SetResponseCreator( tid, rpcName string, creator ResponseCreator, )
SetResponseCreator sets a creator for a RPC.
type RequestCapture ¶
type RequestCapture[RQ, RS protoreflect.ProtoMessage] struct { // contains filtered or unexported fields }
func NewRequestCapture ¶
func NewRequestCapture[RQ, RS protoreflect.ProtoMessage]( res RS, err error, ) *RequestCapture[RQ, RS]
func (*RequestCapture[RQ, RS]) Creator ¶
func (rc *RequestCapture[RQ, RS]) Creator( ctx context.Context, req RQ, ) (RS, error)
func (*RequestCapture[RQ, RS]) Get ¶
func (rc *RequestCapture[RQ, RS]) Get() RQ
type ResponseBuilder ¶
type ResponseBuilder[RQ, RS protoreflect.ProtoMessage] struct { // contains filtered or unexported fields }
ResponseBuilder builds a ResponseCreator which returns a sequence of response/errors.
func (*ResponseBuilder[RQ, RS]) Append ¶
func (rb *ResponseBuilder[RQ, RS]) Append( res RS, err error, )
type ResponseCreator ¶
ResponseCreator is a function to create response and error.