Documentation ¶
Index ¶
- Variables
- func Dial(addr string, opts ...DialOption) (*grpc.ClientConn, error)
- func EnsureValidResponseCode(code int) int
- func GetGRPCErrorFromHTTPResponse(resp *httppb.HandleSimpleHTTPResponse) error
- func GetHTTPHeader(hs http.Header) []*httppb.Element
- func GetHTTPResponseFromError(err error) (*httppb.HandleSimpleHTTPResponse, bool)
- func MergeHTTPHeader(hs []*httppb.Element, header http.Header)
- func NewListener() (net.Listener, error)
- func NewServer(opts ...ServerOption) *grpc.Server
- func Serve(listener net.Listener, grpcServer *grpc.Server)
- func TimestampAsTime(ts *tspb.Timestamp) (time.Time, error)
- func TimestampFromTime(time time.Time) *tspb.Timestamp
- type DialOption
- type DialOptions
- type ServerCloser
- type ServerOption
- type ServerOptions
Constants ¶
This section is empty.
Variables ¶
var DefaultDialOptions = []grpc.DialOption{ grpc.WithDefaultCallOptions( grpc.MaxCallRecvMsgSize(math.MaxInt), grpc.MaxCallSendMsgSize(math.MaxInt), grpc.WaitForReady(defaultWaitForReady), ), grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: defaultClientKeepAliveTime, Timeout: defaultClientKeepAliveTimeOut, PermitWithoutStream: defaultPermitWithoutStream, }), grpc.WithTransportCredentials(insecure.NewCredentials()), }
var DefaultServerOptions = []grpc.ServerOption{ grpc.MaxRecvMsgSize(math.MaxInt), grpc.MaxSendMsgSize(math.MaxInt), grpc.MaxConcurrentStreams(math.MaxUint32), grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ MinTime: defaultServerKeepAliveMinTime, PermitWithoutStream: defaultPermitWithoutStream, }), grpc.KeepaliveParams(keepalive.ServerParameters{ Time: defaultServerKeepAliveInterval, Timeout: defaultServerKeepAliveTimeout, }), }
Functions ¶
func Dial ¶ added in v1.7.10
func Dial(addr string, opts ...DialOption) (*grpc.ClientConn, error)
gRPC clients created from this ClientConn will wait forever for the Server to become Ready. If you desire a dial timeout ensure context is properly plumbed to the client and use context.WithTimeout.
Dial returns a gRPC ClientConn with the dial options as defined by DefaultDialOptions. DialOption can also optionally be passed.
func EnsureValidResponseCode ¶ added in v1.7.11
EnsureValidResponseCode ensures that the response code is valid otherwise it returns 500.
func GetGRPCErrorFromHTTPResponse ¶ added in v1.7.7
func GetGRPCErrorFromHTTPResponse(resp *httppb.HandleSimpleHTTPResponse) error
GetGRPCErrorFromHTTPResponse takes an HandleSimpleHTTPResponse as input and returns a gRPC error.
func GetHTTPHeader ¶ added in v1.7.7
GetHTTPHeader takes an http.Header as input and returns a slice of Header.
func GetHTTPResponseFromError ¶ added in v1.7.7
func GetHTTPResponseFromError(err error) (*httppb.HandleSimpleHTTPResponse, bool)
GetHTTPResponseFromError takes an gRPC error as input and returns a gRPC HandleSimpleHTTPResponse.
func MergeHTTPHeader ¶ added in v1.7.7
MergeHTTPHeader takes a slice of Header and merges with http.Header map.
func NewListener ¶ added in v1.7.10
NewListener returns a TCP listener listening against the next available port on the system bound to localhost.
func NewServer ¶ added in v1.9.9
func NewServer(opts ...ServerOption) *grpc.Server
NewServer will return a gRPC server with server options as defined by DefaultServerOptions. ServerOption can also optionally be passed.
func Serve ¶ added in v1.7.10
Serve will start a gRPC server and block until it errors or is shutdown.
func TimestampAsTime ¶ added in v1.7.11
TimestampAsTime validates timestamppb timestamp and returns time.Time.
Types ¶
type DialOption ¶ added in v1.9.9
type DialOption func(*DialOptions)
func WithChainStreamInterceptor ¶ added in v1.9.9
func WithChainStreamInterceptor(interceptors ...grpc.StreamClientInterceptor) DialOption
WithChainStreamInterceptor takes a list of stream client interceptors which are added to the dial options.
func WithChainUnaryInterceptor ¶ added in v1.9.9
func WithChainUnaryInterceptor(interceptors ...grpc.UnaryClientInterceptor) DialOption
WithChainUnaryInterceptor takes a list of unary client interceptors which are added to the dial options.
type DialOptions ¶ added in v1.9.9
type DialOptions struct {
// contains filtered or unexported fields
}
DialOptions are options which can be applied to a gRPC client in addition to the defaults set by DefaultDialOptions.
type ServerCloser ¶
type ServerCloser struct {
// contains filtered or unexported fields
}
func (*ServerCloser) Add ¶
func (s *ServerCloser) Add(server *grpc.Server)
func (*ServerCloser) GracefulStop ¶ added in v1.1.4
func (s *ServerCloser) GracefulStop()
func (*ServerCloser) Stop ¶
func (s *ServerCloser) Stop()
type ServerOption ¶ added in v1.9.9
type ServerOption func(*ServerOptions)
ServerOption are options which can be applied to a gRPC server in addition to the defaults set by DefaultServerOPtions.
func WithStreamInterceptor ¶ added in v1.9.9
func WithStreamInterceptor(streamInterceptor grpc.StreamServerInterceptor) ServerOption
WithStreamInterceptor adds a single stream interceptor to the gRPC server options.
func WithUnaryInterceptor ¶ added in v1.9.9
func WithUnaryInterceptor(unaryInterceptor grpc.UnaryServerInterceptor) ServerOption
WithUnaryInterceptor adds a single unary interceptor to the gRPC server options.
type ServerOptions ¶ added in v1.9.9
type ServerOptions struct {
// contains filtered or unexported fields
}