Documentation ¶
Index ¶
Constants ¶
View Source
const ( // DefaultName default server name DefaultName = "mkit.service.default" // DefaultAddress random port DefaultAddress = ":0" // DefaultMaxRecvMsgSize maximum message that client can receive // (16 MB). DefaultMaxRecvMsgSize = 1024 * 1024 * 16 // DefaultMaxSendMsgSize maximum message that client can send // (16 MB). DefaultMaxSendMsgSize = 1024 * 1024 * 16 )
Variables ¶
This section is empty.
Functions ¶
func NewClient ¶
func NewClient(target string, opts ...ClientOption) (*grpc.ClientConn, error)
NewClient creates and returns a new grpc client connection Users should call ClientConn.Close() to terminate all the pending operations. also keep track of all clients so that, it disconnect client connections gracefully on kill signal. throw error if connection fail or if there is already a client created with same name
func SetServingStatus ¶
func SetServingStatus(service string, servingStatus grpc_health_v1.HealthCheckResponse_ServingStatus)
SetServingStatus updates service health status. concurrency safe
Types ¶
type ClientOption ¶
type ClientOption func(*ClientOptions)
func WithDialOptions ¶
func WithDialOptions(opts ...grpc.DialOption) ClientOption
WithDialOptions DialOptions for client
type ClientOptions ¶
type ClientOptions struct { Name string DialOptions []grpc.DialOption Context context.Context }
type Server ¶
type Server interface { // Server returns grpc server previously created with NewServer() Server() *grpc.Server // Client creates and returns a new grpc client connection // Users should call ClientConn.Close() to terminate all the pending operations. // also keep track of all clients so that, it disconnect client connections gracefully on kill signal. // throw error if connection fail or if there is already a client created with same name Client(target string, opts ...ClientOption) (*grpc.ClientConn, error) // SetServingStatus updates service health status. concurrency safe // empty service string represents the health of the whole system SetServingStatus(service string, servingStatus grpc_health_v1.HealthCheckResponse_ServingStatus) Start() error // Stop will force stop server Stop() }
Server is a grpc Server
var DefaultServer Server
type ServerOption ¶
type ServerOption func(*ServerOptions)
func Context ¶
func Context(ctx context.Context) ServerOption
Context appContext to trigger terminate signal
func WithListener ¶
func WithListener(listener net.Listener) ServerOption
WithListener specifies the net.Listener to use instead of the default
func WithServerOptions ¶
func WithServerOptions(opts ...grpc.ServerOption) ServerOption
WithServerOptions ServerOptions for server
type ServerOptions ¶
Click to show internal directories.
Click to hide internal directories.