Documentation
¶
Index ¶
Constants ¶
View Source
const ( // MaxConcurrentStreamsFieldName максимальное количество одновременных стримов MaxConcurrentStreamsFieldName = "server.grpc.max_concurrent_streams" // MinTimeFieldName минимальное время между keepalive пингами MinTimeFieldName = "server.grpc.min_time" // PermitWithoutStreamFieldName разрешать keepalive без активных стримов PermitWithoutStreamFieldName = "server.grpc.permit_without_stream" // KeepaliveTimeFieldName интервал keepalive пингов KeepaliveTimeFieldName = "server.grpc.keepalive.time" // KeepaliveTimeoutFieldName таймаут keepalive KeepaliveTimeoutFieldName = "server.grpc.keepalive.timeout" // InterfaceFieldName сетевой интерфейс InterfaceFieldName = "server.grpc.interface" // PortFieldName порт PortFieldName = "server.grpc.port" )
Variables ¶
View Source
var ( MaxConcurrentStreamsDefault = uint32(1000) MinTimeDefault = time.Second PermitWithoutStreamDefault = true KeepaliveTimeDefault = time.Second * 10 KeepaliveTimeoutDefault = time.Second * 20 InterfaceDefault = "0.0.0.0" PortDefault = uint16(9090) )
View Source
var Component = compogo.Component{ Dependencies: compogo.Components{ &runner.Component, }, Init: compogo.StepFunc(func(container compogo.Container) error { return container.Provides( NewConfig, NewServer, ) }), BindFlags: compogo.BindFlags(func(flagSet flag.FlagSet, container compogo.Container) error { return container.Invoke(func(config *Config) { flagSet.BoolVar(&config.PermitWithoutStream, PermitWithoutStreamFieldName, PermitWithoutStreamDefault, "") flagSet.Uint16Var(&config.Port, PortFieldName, PortDefault, "") flagSet.Uint32Var(&config.MaxConcurrentStreams, MaxConcurrentStreamsFieldName, MaxConcurrentStreamsDefault, "") flagSet.StringVar(&config.Interface, InterfaceFieldName, InterfaceDefault, "") flagSet.DurationVar(&config.MinTime, MinTimeFieldName, MinTimeDefault, "") flagSet.DurationVar(&config.KeepaliveTime, KeepaliveTimeFieldName, KeepaliveTimeDefault, "") flagSet.DurationVar(&config.KeepaliveTimeout, KeepaliveTimeoutFieldName, KeepaliveTimeoutDefault, "") }) }), Configuration: compogo.StepFunc(func(container compogo.Container) error { return container.Invoke(Configuration) }), Execute: compogo.StepFunc(func(container compogo.Container) error { return container.Invoke(func(r runner.Runner, server *Server) error { return r.RunProcess(server) }) }), Stop: compogo.StepFunc(func(container compogo.Container) error { return container.Invoke(func(server *Server) error { return server.Close() }) }), }
Component — компонент GRPC-сервера для Compogo. Регистрирует сервер в DI-контейнере и запускает его через Runner.
Пример:
app.AddComponents(&grpc_server.Component)
var s *grpc_server.Server
container.Invoke(func(server *grpc_server.Server) { s = server })
service.RegisterMyServiceServer(s.GetGRPC(), &MyService{})
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
PermitWithoutStream bool
Port uint16
MaxConcurrentStreams uint32
Interface string
MinTime time.Duration
KeepaliveTime time.Duration
KeepaliveTimeout time.Duration
}
Config содержит конфигурацию GRPC-сервера.
func Configuration ¶
func Configuration(config *Config, configurator compogo.Configurator) *Config
Configuration загружает конфигурацию из Configurator.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server представляет GRPC-сервер с поддержкой graceful shutdown.
Click to show internal directories.
Click to hide internal directories.