Documentation ¶
Index ¶
- Constants
- func NewClient(target string, opts ...ClientOption) (*grpc.ClientConn, error)
- func SetServingStatus(service string, servingStatus grpc_health_v1.HealthCheckResponse_ServingStatus)
- func Start() error
- type ClientConfiguration
- type ClientOption
- type ClientOptions
- type Server
- type ServerConfiguration
- type ServerOption
- type ServerOptions
Constants ¶
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 disconnects 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 ClientConfiguration ¶ added in v0.3.0
type ClientConfiguration struct { Endpoints []string `json:",optional"` Target string `json:",optional"` App string `json:",optional"` Token string `json:",optional"` NonBlock bool `json:",optional"` Timeout int64 `json:",default=2000"` }
ClientConfiguration is for gRPC client config.
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 ServerConfiguration ¶ added in v0.3.0
type ServerConfiguration struct { Name string Log string Mode string `json:",default=pro,options=dev|test|rt|pre|pro"` MetricsURL string `json:",optional"` Telemetry trace.Config `json:",optional"` ListenOn string Auth bool `json:",optional"` StrictControl bool `json:",optional"` // setting 0 means no timeout Timeout int64 `json:",default=2000"` CPUThreshold int64 `json:",default=900,range=[0:1000]"` }
ServerConfiguration is for gRPC server config.
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