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(_ context.Context, req interface{}) (common.Namespace, error) { r, ok := req.(*PingQuery) if !ok { return common.Namespace{}, errInvalidRequestType } return r.Namespace, nil }).WithAccessControl(cmnGrpc.AccessControlAlways) // MethodWatchPings is the WatchPings method. MethodWatchPings = serviceName.NewMethod("WatchPings", PingQuery{}). WithNamespaceExtractor(func(_ context.Context, req interface{}) (common.Namespace, error) { r, ok := req.(*PingQuery) if !ok { return common.Namespace{}, errInvalidRequestType } return r.Namespace, nil }).WithAccessControl(cmnGrpc.AccessControlAlways) )
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) (<-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, req interface{}) error) PingServer
NewPingServer retruns a new Ping server.
Click to show internal directories.
Click to hide internal directories.