Documentation ¶
Index ¶
- Variables
- func Dial(addr string, opts ...DialOption) (*grpc.ClientConn, error)
- func EnsureValidResponseCode(code int) int
- func Errorf(code int, tmpl string, args ...interface{}) error
- 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 ¶
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 ¶
EnsureValidResponseCode ensures that the response code is valid otherwise it returns 500.
func GetGRPCErrorFromHTTPResponse ¶
func GetGRPCErrorFromHTTPResponse(resp *httppb.HandleSimpleHTTPResponse) error
GetGRPCErrorFromHTTPRespone takes an HandleSimpleHTTPResponse as input and returns a gRPC error.
func GetHTTPHeader ¶
GetHTTPHeader takes an http.Header as input and returns a slice of Header.
func GetHTTPResponseFromError ¶
func GetHTTPResponseFromError(err error) (*httppb.HandleSimpleHTTPResponse, bool)
GetHTTPResponseFromError takes an gRPC error as input and returns a gRPC HandleSimpleHTTPResponse.
func MergeHTTPHeader ¶
MergeHTTPHeader takes a slice of Header and merges with http.Header map.
func NewListener ¶
NewListener returns a TCP listener listening against the next available port on the system bound to localhost.
func NewServer ¶
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 TimestampAsTime ¶
TimestampAsTime validates timestamppb timestamp and returns time.Time.
Types ¶
type DialOption ¶
type DialOption func(*DialOptions)
func WithChainStreamInterceptor ¶
func WithChainStreamInterceptor(interceptors ...grpc.StreamClientInterceptor) DialOption
WithChainStreamInterceptor takes a list of stream client interceptors which are added to the dial options.
func WithChainUnaryInterceptor ¶
func WithChainUnaryInterceptor(interceptors ...grpc.UnaryClientInterceptor) DialOption
WithChainUnaryInterceptor takes a list of unary client interceptors which are added to the dial options.
type DialOptions ¶
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 ¶
func (s *ServerCloser) GracefulStop()
func (*ServerCloser) Stop ¶
func (s *ServerCloser) Stop()
type ServerOption ¶
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 ¶
func WithStreamInterceptor(streamInterceptor grpc.StreamServerInterceptor) ServerOption
WithStreamInterceptor adds a single stream interceptor to the gRPC server options.
func WithUnaryInterceptor ¶
func WithUnaryInterceptor(unaryInterceptor grpc.UnaryServerInterceptor) ServerOption
WithUnaryInterceptor adds a single unary interceptor to the gRPC server options.
type ServerOptions ¶
type ServerOptions struct {
// contains filtered or unexported fields
}