Documentation ¶
Overview ¶
Package grpc implements a run.Group compatible gRPC server.
Index ¶
- Constants
- func NewStatsHandler(handlers ...stats.Handler) stats.Handler
- func StatusError(c codes.Code, msg string) error
- type Interceptors
- func (i *Interceptors) AddServerOption(so ...grpc.ServerOption)
- func (i *Interceptors) AddStatsHandler(handlers ...stats.Handler)
- func (i *Interceptors) AddStreamClient(sc ...grpc.StreamClientInterceptor)
- func (i *Interceptors) AddStreamServer(ss ...grpc.StreamServerInterceptor)
- func (i *Interceptors) AddUnaryClient(uc ...grpc.UnaryClientInterceptor)
- func (i *Interceptors) AddUnaryServer(us ...grpc.UnaryServerInterceptor)
- func (i *Interceptors) GetDialOptions() []grpc.DialOption
- func (i *Interceptors) GetServerOptions() []grpc.ServerOption
- type Service
- func (s *Service) Attach(fn func(*grpc.Server))
- func (s *Service) FlagSet() *run.FlagSet
- func (s *Service) GetGrpcAddress() (string, error)
- func (s *Service) GracefulStop()
- func (s *Service) Interceptors() *Interceptors
- func (s *Service) Name() string
- func (s *Service) Serve() error
- func (s *Service) Validate() error
- type StatsHandler
- func (s *StatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats)
- func (s *StatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)
- func (s *StatsHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context
- func (s *StatsHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context
Constants ¶
const ( ServerListenAddress = "grpc-listen-address" MaxGRPCStreamMsgSize = "max-grpc-stream-msg-size" )
package flags.
Variables ¶
This section is empty.
Functions ¶
func NewStatsHandler ¶
NewStatsHandler chains multiple stats.Handler implementations into one.
Types ¶
type Interceptors ¶
type Interceptors struct {
// contains filtered or unexported fields
}
Interceptors holds collections of gRPC server and client interceptors which can be added to and allows them to be chained in a gRPC server or client.
func (*Interceptors) AddServerOption ¶
func (i *Interceptors) AddServerOption(so ...grpc.ServerOption)
AddServerOption allows to add custom server options to a gRPC server.
func (*Interceptors) AddStatsHandler ¶
func (i *Interceptors) AddStatsHandler(handlers ...stats.Handler)
AddStatsHandler allows one or more stats.Handlers to be registered.
func (*Interceptors) AddStreamClient ¶
func (i *Interceptors) AddStreamClient(sc ...grpc.StreamClientInterceptor)
AddStreamClient allows one or more StreamClientInterceptor to be registered.
func (*Interceptors) AddStreamServer ¶
func (i *Interceptors) AddStreamServer(ss ...grpc.StreamServerInterceptor)
AddStreamServer allows one or more StreamServerInterceptor to be registered.
func (*Interceptors) AddUnaryClient ¶
func (i *Interceptors) AddUnaryClient(uc ...grpc.UnaryClientInterceptor)
AddUnaryClient allows one or more UnaryClientInterceptors to be registered.
func (*Interceptors) AddUnaryServer ¶
func (i *Interceptors) AddUnaryServer(us ...grpc.UnaryServerInterceptor)
AddUnaryServer allows one or more UnaryServerInterceptors to be registered.
func (*Interceptors) GetDialOptions ¶
func (i *Interceptors) GetDialOptions() []grpc.DialOption
GetDialOptions returns an array of grpc.DialOptions composed of the registered chained ClientInterceptors.
func (*Interceptors) GetServerOptions ¶
func (i *Interceptors) GetServerOptions() []grpc.ServerOption
GetServerOptions returns an array of grpc.ServerOptions composed of the registered chained ServerInterceptors.
type Service ¶
type Service struct { Address string MaxGRPCStreamMsgSize int Options []grpc.ServerOption *grpc.Server // contains filtered or unexported fields }
Service implements a run.Group compatible gRPC server.
func (*Service) Attach ¶
Attach allows one to register gRPC services to this server. Once the actual gRPC server is created, the registration function provided to this call will be executed. (during the run.Group Serve stage).
func (*Service) GetGrpcAddress ¶
GetGrpcAddress returns the grpc address assigned to the server instance. If the address is not configured, an error is returned.
func (*Service) GracefulStop ¶
func (s *Service) GracefulStop()
GracefulStop implements run.Service.
func (*Service) Interceptors ¶
func (s *Service) Interceptors() *Interceptors
Interceptors returns the Interceptors handler for this gRPC Service.
type StatsHandler ¶
type StatsHandler struct {
// contains filtered or unexported fields
}
StatsHandler provides the ability to chain multiple grpc/stats.Handler into a single one to be consumed by a gRPC service.
func (*StatsHandler) HandleConn ¶
func (s *StatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats)
HandleConn implements stats.Handler.
func (*StatsHandler) HandleRPC ¶
func (s *StatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)
HandleRPC implements stats.Handler.
func (*StatsHandler) TagConn ¶
func (s *StatsHandler) TagConn(ctx context.Context, cti *stats.ConnTagInfo) context.Context
TagConn implements stats.Handler.
func (*StatsHandler) TagRPC ¶
func (s *StatsHandler) TagRPC(ctx context.Context, rti *stats.RPCTagInfo) context.Context
TagRPC implements stats.Handler.