Documentation ¶
Index ¶
- Constants
- Variables
- func FromContextAny(ctx context.Context, key string) interface{}
- func InterfaceStreamServerInterceptor(name string, val interface{}) grpc.StreamServerInterceptor
- func InterfaceUnaryServerInterceptor(name string, val interface{}) grpc.UnaryServerInterceptor
- func WithContextAny(ctx context.Context, key string, val interface{}) context.Context
- func WrapperStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
- func WrapperUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
- type Config
- type GRPCRegisterServiceFunc
- type Option
- func Addr(a string) Option
- func Description(d string) Option
- func Discovery(d discovery.Discovery) Option
- func GRPCRegister(fn GRPCRegisterServiceFunc) Option
- func ID(id string) Option
- func Logger(l zerolog.Logger) Option
- func Middlewares(m ...router.Middleware) Option
- func Mux(m *router.Router) Option
- func Name(n string) Option
- func ReadTimeout(t time.Duration) Option
- func StreamServerInterceptors(i ...grpc.StreamServerInterceptor) Option
- func TLSConfig(certFile, keyFile string) Option
- func UnaryServerInterceptors(i ...grpc.UnaryServerInterceptor) Option
- func WriteTimeout(t time.Duration) Option
- type Server
- func (s *Server) Health() *healthpb.HealthCheckResponse
- func (s *Server) Logger() zerolog.Logger
- func (s *Server) Name() string
- func (s *Server) Run(opts ...Option) error
- func (s *Server) Stop()
- func (s *Server) WithContext(ctx context.Context) context.Context
- func (s *Server) WithOptions(opts ...Option) *Server
- type ServerStreamWithContext
- func (w *ServerStreamWithContext) Context() context.Context
- func (w *ServerStreamWithContext) RecvMsg(msg interface{}) error
- func (w *ServerStreamWithContext) SendHeader(md metadata.MD) error
- func (w *ServerStreamWithContext) SendMsg(msg interface{}) error
- func (w *ServerStreamWithContext) SetContext(ctx context.Context)
- func (w *ServerStreamWithContext) SetHeader(md metadata.MD) error
- func (w *ServerStreamWithContext) SetTrailer(md metadata.MD)
- type TCPKeepAliveListener
Constants ¶
const (
// DefaultName server prefix name
DefaultName = "server"
)
Variables ¶
var ( // ServerContextKey is a context key. It can be used in HTTP / GRPC // handlers with context.WithValue to access the server that // started the handler. The associated value will be of type *Server. ServerContextKey = &contextKey{"pluto-server"} )
Functions ¶
func FromContextAny ¶
FromContextAny returns from context the interface value to which the key is associated.
func InterfaceStreamServerInterceptor ¶
func InterfaceStreamServerInterceptor(name string, val interface{}) grpc.StreamServerInterceptor
InterfaceStreamServerInterceptor wraps any type to grpc stream server
func InterfaceUnaryServerInterceptor ¶
func InterfaceUnaryServerInterceptor(name string, val interface{}) grpc.UnaryServerInterceptor
InterfaceUnaryServerInterceptor wraps any type to grpc unary server
func WithContextAny ¶
WithContextAny returns a copy of parent ctx in which the value associated with key is val.
func WrapperStreamServer ¶
func WrapperStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor
WrapperStreamServer creates a single interceptor out of a chain of many interceptors Execution is done in right-to-left order
func WrapperUnaryServer ¶
func WrapperUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor
WrapperUnaryServer creates a single interceptor out of a chain of many interceptors Execution is done in right-to-left order
Types ¶
type Config ¶
type Config struct { ID string Name string Description string Addr string // TCP address (e.g. localhost:8000) to listen on, ":http" if empty Format string Mux *router.Router TLSConfig *tls.Config // optional TLS config, used by ListenAndServeTLS GRPCRegister GRPCRegisterServiceFunc Discovery discovery.Discovery ReadTimeout time.Duration WriteTimeout time.Duration Middlewares []router.Middleware // http middlewares UnaryServerInterceptors []grpc.UnaryServerInterceptor // gRPC interceptors StreamServerInterceptors []grpc.StreamServerInterceptor // gRPC interceptors // contains filtered or unexported fields }
Config server configuaration options
type GRPCRegisterServiceFunc ¶
GRPCRegisterServiceFunc grpc
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is used to set options for the server.
func GRPCRegister ¶
func GRPCRegister(fn GRPCRegisterServiceFunc) Option
GRPCRegister register client gRPC function
func Middlewares ¶
func Middlewares(m ...router.Middleware) Option
Middlewares slice with router.Middleware
func ReadTimeout ¶
ReadTimeout is used by the http server to set a maximum duration before timing out read of the request. The default timeout is 10 seconds.
func StreamServerInterceptors ¶
func StreamServerInterceptors(i ...grpc.StreamServerInterceptor) Option
StreamServerInterceptors slice with grpc.StreamServerInterceptor
func UnaryServerInterceptors ¶
func UnaryServerInterceptors(i ...grpc.UnaryServerInterceptor) Option
UnaryServerInterceptors slice with grpc.UnaryServerInterceptor
func WriteTimeout ¶
WriteTimeout is used by the http server to set a maximum duration before timing out write of the response. The default timeout is 10 seconds.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
A Server defines parameters for running an HTTP server. The zero value for Server is a valid configuration.
func FromContext ¶
FromContext returns server instance from a context
func (*Server) Health ¶
func (s *Server) Health() *healthpb.HealthCheckResponse
func (*Server) Stop ¶
func (s *Server) Stop()
Stop stops server by sending a message to close the listener via channel
func (*Server) WithContext ¶
WithContext returns a copy of ctx with server associated.
func (*Server) WithOptions ¶
WithOptions clones the current Client, applies the supplied Options, and returns the resulting Client. It's safe to use concurrently.
type ServerStreamWithContext ¶
type ServerStreamWithContext struct {
// contains filtered or unexported fields
}
https://groups.google.com/forum/#!topic/grpc-io/Q88GQFTPF1o
func WrapServerStreamWithContext ¶
func WrapServerStreamWithContext(stream grpc.ServerStream) *ServerStreamWithContext
WrapServerStreamWrapper returns a ServerStream that has the ability to overwrite context.
func (*ServerStreamWithContext) Context ¶
func (w *ServerStreamWithContext) Context() context.Context
Stream interface
func (*ServerStreamWithContext) RecvMsg ¶
func (w *ServerStreamWithContext) RecvMsg(msg interface{}) error
func (*ServerStreamWithContext) SendHeader ¶
func (w *ServerStreamWithContext) SendHeader(md metadata.MD) error
ServerStream interface
func (*ServerStreamWithContext) SendMsg ¶
func (w *ServerStreamWithContext) SendMsg(msg interface{}) error
func (*ServerStreamWithContext) SetContext ¶
func (w *ServerStreamWithContext) SetContext(ctx context.Context)
func (*ServerStreamWithContext) SetHeader ¶
func (w *ServerStreamWithContext) SetHeader(md metadata.MD) error
func (*ServerStreamWithContext) SetTrailer ¶
func (w *ServerStreamWithContext) SetTrailer(md metadata.MD)
type TCPKeepAliveListener ¶
type TCPKeepAliveListener struct {
*net.TCPListener
}
TCPKeepAliveListener is a copy of tcpKeepAliveListener source: net/http/server.go
tcpKeepAliveListener sets TCP keep-alive timeouts on accepted connections. It's used by ListenAndServe and ListenAndServeTLS so dead TCP connections (e.g. closing laptop mid-download) eventually go away.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package router trie based on a 256-way trie expressed on the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne A string symbol table for extended ASCII strings, implemented using a 256-way trie.
|
Package router trie based on a 256-way trie expressed on the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne A string symbol table for extended ASCII strings, implemented using a 256-way trie. |