Documentation ¶
Overview ¶
Package testing implements common grpc testing helpers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // MethodPing is the Ping method. MethodPing = serviceName.NewMethod("Ping", PingQuery{}). WithNamespaceExtractor(func(ctx context.Context, req interface{}) (common.Namespace, error) { r, ok := req.(*PingQuery) if !ok { return common.Namespace{}, errInvalidRequestType } return r.Namespace, nil }).WithAccessControl(func(ctx context.Context, req interface{}) (bool, error) { return true, nil }) // MethodWatchPings is the WatchPings method. MethodWatchPings = serviceName.NewMethod("WatchPings", PingQuery{}). WithNamespaceExtractor(func(ctx context.Context, req interface{}) (common.Namespace, error) { r, ok := req.(*PingQuery) if !ok { return common.Namespace{}, errInvalidRequestType } return r.Namespace, nil }).WithAccessControl(func(ctx context.Context, req interface{}) (bool, error) { return true, nil }) )
View Source
var ServiceDesc = grpc.ServiceDesc{ ServiceName: string(serviceName), HandlerType: (*PingServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: MethodPing.ShortName(), Handler: pingHandler, }, }, Streams: []grpc.StreamDesc{ { StreamName: MethodWatchPings.ShortName(), Handler: watchPingsHandler, ServerStreams: true, }, }, }
ServiceDesc is the PingService gRPC description.
Functions ¶
func CreateCertificate ¶
func CreateCertificate(t *testing.T) (*tls.Certificate, *x509.Certificate)
CreateCertificate creates gRPC TLS certificate for testing.
func RegisterService ¶
func RegisterService(server *grpc.Server, service PingServer)
RegisterService registers a new ping server service with the given gRPC server.
Types ¶
type PingClient ¶
type PingClient interface { Ping(ctx context.Context, in *PingQuery, opts ...grpc.CallOption) (*PingResponse, error) WatchPings(ctx context.Context, in *PingQuery, opts ...grpc.CallOption) (<-chan *PingResponse, pubsub.ClosableSubscription, error) MissingMethod(ctx context.Context, in *PingQuery, opts ...grpc.CallOption) (*PingResponse, error) }
PingClient is a testing PingServer client.
func NewPingClient ¶
func NewPingClient(conn *grpc.ClientConn) PingClient
NewPingClient returns a new ping client.
type PingServer ¶
type PingServer interface { Ping(context.Context, *PingQuery) (*PingResponse, error) WatchPings(context.Context, *PingQuery) (<-chan *PingResponse, pubsub.ClosableSubscription, error) }
PingServer is a testing ping server interface.
func NewPingServer ¶
func NewPingServer(authFunc func(ctx context.Context, fullMethodName string, req interface{}) error) PingServer
NewPingServer retruns a new Ping server.
Click to show internal directories.
Click to hide internal directories.