Documentation ¶
Index ¶
- Constants
- func New(name string, definer ServiceDefiner, middlewares ...MiddlewareFactory) kernel.ModuleFactory
- func NewHealthServer(logger log.Logger, cancelFunc context.CancelFunc) *healthServer
- func NewStatsHandler(logger log.Logger, settings *Settings) *statsHandler
- type Definitions
- type Health
- type HealthCheckCallback
- type Middleware
- type MiddlewareFactory
- type Registrant
- type Server
- type ServiceDefiner
- type ServiceHealthCallback
- type Settings
- type Stats
Constants ¶
const ( MetricApiRequestCount = "ApiRequestCount" MetricApiRequestResponseTime = "ApiRequestResponseTime" MetricDimensionFullMethod = "full_method" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(name string, definer ServiceDefiner, middlewares ...MiddlewareFactory) kernel.ModuleFactory
New returns a kernel.ModuleFactory for the Server kernel.Module.
func NewHealthServer ¶
func NewHealthServer(logger log.Logger, cancelFunc context.CancelFunc) *healthServer
NewHealthServer returns a new HealthServer.
func NewStatsHandler ¶
Types ¶
type Definitions ¶
type Definitions []definition
Definitions is a collection that is used to initialize the Server.
During the initialisation the Registrant function will be called.
func (*Definitions) Add ¶
func (s *Definitions) Add(name string, registrant Registrant) *Definitions
Add a new definition by providing the service name and the registrant.
func (*Definitions) AddWithHealthCheckCallback ¶
func (s *Definitions) AddWithHealthCheckCallback(name string, registrant Registrant, healthCheckCallback HealthCheckCallback) *Definitions
AddWithHealthCheckCallback a new definition by providing the service name, the registrant and the HealthCheckCallback.
type Health ¶
type Health struct { // Enabled determines if the default health.checks will be used // the default health-checks utilizes the google.golang.org/grpc/health/grpc_health_v1 pkg. Enabled bool `cfg:"enabled" default:"true"` }
Health settings of the Server.
type HealthCheckCallback ¶
type HealthCheckCallback func(ctx context.Context) protobuf.HealthCheckResponse_ServingStatus
HealthCheckCallback the signature of the HealthCheckCallback.
type Middleware ¶
type Middleware grpc.UnaryServerInterceptor
type MiddlewareFactory ¶
type MiddlewareFactory func(logger log.Logger) Middleware
type Registrant ¶
Registrant is a function callback that receives a cancelFunc and a grpc.Server and should be implemented to add the gRPC services to the grpc.Server.
type Server ¶
type Server struct { kernel.EssentialModule kernel.ServiceStage // contains filtered or unexported fields }
Server a basic grpc.Server wrapper that allows also can have a basic Health Check functionality.
func NewWithInterfaces ¶
func NewWithInterfaces(ctx context.Context, logger log.Logger, definitions *Definitions, s *Settings, middlewares ...MiddlewareFactory) (*Server, error)
NewWithInterfaces receives the interfaces required to create a Server.
type ServiceDefiner ¶
type ServiceDefiner func(ctx context.Context, config cfg.Config, logger log.Logger) (*Definitions, error)
ServiceDefiner is used to initialise the Server module.
This function is used to initialise your dependencies i.e. the services.
type ServiceHealthCallback ¶
type ServiceHealthCallback struct { ServiceName string HealthCheckCallback HealthCheckCallback }
ServiceHealthCallback definition.
type Settings ¶
type Settings struct { // Port where the grpc.Server will be listening to. Port string `cfg:"port" default:"8081"` // Health related settings. Health Health `cfg:"health"` // Statistics related settings. Stats Stats `cfg:"stats"` }
Settings of the Server.
type Stats ¶
type Stats struct { // Enabled defines if the statistics handler is enabled. Enabled bool `cfg:"enabled" default:"true"` // LogLevel defines the log level for the statistics logs LogLevel string `cfg:"log_level" default:"debug" validate:"oneof=debug info"` // LogPayload defines whether to log the incoming and outgoing payloads of a gRPC method. LogPayload bool `cfg:"log_payload" default:"false"` // LogData defines whether to log the incoming and outgoing raw data of a gRPC method. LogData bool `cfg:"log_data" default:"false"` // Channel to log the statistics to. Channel string `cfg:"channel" default:"grpc_stats"` }