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
- type WebHandler
- type Web_Net
Constants ¶
This section is empty.
Variables ¶
var File_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 // 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 WithGetViper ¶ added in v0.0.21
func WithGetViper(f func() *viper.Viper) ConfigOption
func WithShutdownDelayDuration ¶ added in v0.0.21
func WithShutdownDelayDuration(shutdownDelayDuration time.Duration) 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 // 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"` // 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) 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 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