Documentation ¶
Index ¶
- Variables
- type CompletedConfig
- type Config
- type ConfigOption
- type ConfigOptionFunc
- type EmptyConfigOption
- type GenericWebServer
- func (s *GenericWebServer) AddPostStartHook(name string, hook PostStartHookFunc) error
- func (s *GenericWebServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc)
- func (s *GenericWebServer) AddPreShutdownHook(name string, hook PreShutdownHookFunc) error
- func (s *GenericWebServer) AddPreShutdownHookOrDie(name string, hook PreShutdownHookFunc)
- func (s *GenericWebServer) InstallWebHandlers(handlers ...WebHandler)
- func (s *GenericWebServer) PrepareRun() (preparedGenericWebServer, error)
- func (s *GenericWebServer) RunPostStartHooks(ctx context.Context)
- func (s *GenericWebServer) RunPreShutdownHooks() error
- type PostStartHookFunc
- type PostStartHookProvider
- type PreShutdownHookFunc
- type Web
- func (*Web) Descriptor() ([]byte, []int)deprecated
- func (x *Web) GetBindAddress() *Web_Net
- func (w *Web) GetBindHostPort() string
- func (x *Web) GetMaxConcurrencyStream() int32
- func (x *Web) GetMaxConcurrencyUnary() int32
- func (x *Web) GetMonitor() *Web_Monitor
- func (*Web) ProtoMessage()
- func (x *Web) ProtoReflect() protoreflect.Message
- func (x *Web) Reset()
- func (x *Web) String() string
- type WebHandler
- type Web_Monitor
- type Web_Monitor_Prometheus
- func (*Web_Monitor_Prometheus) Descriptor() ([]byte, []int)deprecated
- func (x *Web_Monitor_Prometheus) GetEnabledMetricCodeMessage() bool
- func (x *Web_Monitor_Prometheus) GetEnabledMetricTimerCost() bool
- func (*Web_Monitor_Prometheus) ProtoMessage()
- func (x *Web_Monitor_Prometheus) ProtoReflect() protoreflect.Message
- func (x *Web_Monitor_Prometheus) Reset()
- func (x *Web_Monitor_Prometheus) String() string
- type Web_Net
Constants ¶
This section is empty.
Variables ¶
var File_pkg_webserver_webserver_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type CompletedConfig ¶
type CompletedConfig struct {
// contains filtered or unexported fields
}
func (CompletedConfig) New ¶
func (c CompletedConfig) New() (*GenericWebServer, error)
type Config ¶
type Config struct { Proto Web Validator *validator.Validate // contains filtered or unexported fields }
func (*Config) ApplyOptions ¶ added in v0.0.21
func (o *Config) ApplyOptions(options ...ConfigOption) *Config
func (*Config) Complete ¶
func (c *Config) Complete() CompletedConfig
Complete set default ServerRunOptions.
type ConfigOption ¶ added in v0.0.21
type ConfigOption interface {
// contains filtered or unexported methods
}
A ConfigOption sets options.
func WithGRPCGatewayOptions ¶ added in v0.0.28
func WithGRPCGatewayOptions(opts ...gw_.GRPCGatewayOption) ConfigOption
func WithShutdownDelayDuration ¶ added in v0.0.21
func WithShutdownDelayDuration(shutdownDelayDuration time.Duration) ConfigOption
func WithViper ¶ added in v0.0.23
func WithViper(v *viper.Viper) ConfigOption
type ConfigOptionFunc ¶ added in v0.0.21
type ConfigOptionFunc func(*Config)
ConfigOptionFunc wraps a function that modifies Client into an implementation of the ConfigOption interface.
type EmptyConfigOption ¶ added in v0.0.21
type EmptyConfigOption struct{}
EmptyConfigOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type GenericWebServer ¶
type GenericWebServer struct { // Server Register. The backend is started after the server starts listening. ServiceRegistryBackend *consul.ServiceRegistryServer // ShutdownDelayDuration allows to block shutdown for some time, e.g. until endpoints pointing to this API server // have converged on all node. During this time, the API server keeps serving, /healthz will return 200, // but /readyz will return failure. ShutdownDelayDuration time.Duration ShutdownTimeoutDuration time.Duration // WebServerID is the ID of this Web server WebServerID string // contains filtered or unexported fields }
func (*GenericWebServer) AddPostStartHook ¶ added in v0.0.20
func (s *GenericWebServer) AddPostStartHook(name string, hook PostStartHookFunc) error
AddPostStartHook allows you to add a PostStartHook.
func (*GenericWebServer) AddPostStartHookOrDie ¶ added in v0.0.20
func (s *GenericWebServer) AddPostStartHookOrDie(name string, hook PostStartHookFunc)
AddPostStartHookOrDie allows you to add a PostStartHook, but dies on failure
func (*GenericWebServer) AddPreShutdownHook ¶ added in v0.0.20
func (s *GenericWebServer) AddPreShutdownHook(name string, hook PreShutdownHookFunc) error
AddPreShutdownHook allows you to add a PreShutdownHook.
func (*GenericWebServer) AddPreShutdownHookOrDie ¶ added in v0.0.20
func (s *GenericWebServer) AddPreShutdownHookOrDie(name string, hook PreShutdownHookFunc)
AddPreShutdownHookOrDie allows you to add a PostStartHook, but dies on failure
func (*GenericWebServer) InstallWebHandlers ¶
func (s *GenericWebServer) InstallWebHandlers(handlers ...WebHandler)
func (*GenericWebServer) PrepareRun ¶
func (s *GenericWebServer) PrepareRun() (preparedGenericWebServer, error)
func (*GenericWebServer) RunPostStartHooks ¶ added in v0.0.20
func (s *GenericWebServer) RunPostStartHooks(ctx context.Context)
RunPostStartHooks runs the PostStartHooks for the server
func (*GenericWebServer) RunPreShutdownHooks ¶ added in v0.0.20
func (s *GenericWebServer) RunPreShutdownHooks() error
RunPreShutdownHooks runs the PreShutdownHooks for the server
type PostStartHookFunc ¶ added in v0.0.20
PostStartHookFunc is a function that is called after the server has started. It must properly handle cases like:
- asynchronous start in multiple API server processes
- conflicts between the different processes all trying to perform the same action
- partially complete work (API server crashes while running your hook)
- API server access **BEFORE** your hook has completed
Think of it like a mini-controller that is super privileged and gets to run in-process If you use this feature, tag @deads2k on github who has promised to review code for anyone's PostStartHook until it becomes easier to use.
type PostStartHookProvider ¶ added in v0.0.20
type PostStartHookProvider interface {
PostStartHook() (string, PostStartHookFunc, error)
}
PostStartHookProvider is an interface in addition to provide a post start hook for the api server
type PreShutdownHookFunc ¶ added in v0.0.20
type PreShutdownHookFunc func() error
PreShutdownHookFunc is a function that can be added to the shutdown logic.
type Web ¶ added in v0.0.20
type Web struct { BindAddress *Web_Net `protobuf:"bytes,1,opt,name=bind_address,json=bindAddress,proto3" json:"bind_address,omitempty"` MaxConcurrencyUnary int32 `protobuf:"varint,2,opt,name=max_concurrency_unary,json=maxConcurrencyUnary,proto3" json:"max_concurrency_unary,omitempty"` MaxConcurrencyStream int32 `protobuf:"varint,3,opt,name=max_concurrency_stream,json=maxConcurrencyStream,proto3" json:"max_concurrency_stream,omitempty"` Monitor *Web_Monitor `protobuf:"bytes,4,opt,name=monitor,proto3" json:"monitor,omitempty"` // contains filtered or unexported fields }
func (*Web) Descriptor
deprecated
added in
v0.0.20
func (*Web) GetBindAddress ¶ added in v0.0.20
func (*Web) GetBindHostPort ¶ added in v0.0.20
func (*Web) GetMaxConcurrencyStream ¶ added in v0.0.31
func (*Web) GetMaxConcurrencyUnary ¶ added in v0.0.31
func (*Web) GetMonitor ¶ added in v0.0.36
func (x *Web) GetMonitor() *Web_Monitor
func (*Web) ProtoMessage ¶ added in v0.0.20
func (*Web) ProtoMessage()
func (*Web) ProtoReflect ¶ added in v0.0.20
func (x *Web) ProtoReflect() protoreflect.Message
type WebHandler ¶
type WebHandler interface {
SetRoutes(ginRouter gin.IRouter, grpcRouter *gw_.GRPCGateway)
}
type Web_Monitor ¶ added in v0.0.36
type Web_Monitor struct { Prometheus *Web_Monitor_Prometheus `protobuf:"bytes,1,opt,name=prometheus,proto3" json:"prometheus,omitempty"` // contains filtered or unexported fields }
func (*Web_Monitor) Descriptor
deprecated
added in
v0.0.36
func (*Web_Monitor) Descriptor() ([]byte, []int)
Deprecated: Use Web_Monitor.ProtoReflect.Descriptor instead.
func (*Web_Monitor) GetPrometheus ¶ added in v0.0.36
func (x *Web_Monitor) GetPrometheus() *Web_Monitor_Prometheus
func (*Web_Monitor) ProtoMessage ¶ added in v0.0.36
func (*Web_Monitor) ProtoMessage()
func (*Web_Monitor) ProtoReflect ¶ added in v0.0.36
func (x *Web_Monitor) ProtoReflect() protoreflect.Message
func (*Web_Monitor) Reset ¶ added in v0.0.36
func (x *Web_Monitor) Reset()
func (*Web_Monitor) String ¶ added in v0.0.36
func (x *Web_Monitor) String() string
type Web_Monitor_Prometheus ¶ added in v0.0.36
type Web_Monitor_Prometheus struct { EnabledMetricTimerCost bool `` /* 132-byte string literal not displayed */ EnabledMetricCodeMessage bool `` /* 138-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Web_Monitor_Prometheus) Descriptor
deprecated
added in
v0.0.36
func (*Web_Monitor_Prometheus) Descriptor() ([]byte, []int)
Deprecated: Use Web_Monitor_Prometheus.ProtoReflect.Descriptor instead.
func (*Web_Monitor_Prometheus) GetEnabledMetricCodeMessage ¶ added in v0.0.36
func (x *Web_Monitor_Prometheus) GetEnabledMetricCodeMessage() bool
func (*Web_Monitor_Prometheus) GetEnabledMetricTimerCost ¶ added in v0.0.36
func (x *Web_Monitor_Prometheus) GetEnabledMetricTimerCost() bool
func (*Web_Monitor_Prometheus) ProtoMessage ¶ added in v0.0.36
func (*Web_Monitor_Prometheus) ProtoMessage()
func (*Web_Monitor_Prometheus) ProtoReflect ¶ added in v0.0.36
func (x *Web_Monitor_Prometheus) ProtoReflect() protoreflect.Message
func (*Web_Monitor_Prometheus) Reset ¶ added in v0.0.36
func (x *Web_Monitor_Prometheus) Reset()
func (*Web_Monitor_Prometheus) String ¶ added in v0.0.36
func (x *Web_Monitor_Prometheus) String() string
type Web_Net ¶ added in v0.0.20
type Web_Net struct { Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"` Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` // contains filtered or unexported fields }
func (*Web_Net) Descriptor
deprecated
added in
v0.0.20
func (*Web_Net) ProtoMessage ¶ added in v0.0.20
func (*Web_Net) ProtoMessage()
func (*Web_Net) ProtoReflect ¶ added in v0.0.20
func (x *Web_Net) ProtoReflect() protoreflect.Message