Documentation ¶
Overview ¶
Package server defines the generic apiserver used by all iam platform.
Package server runs a http server used to provide a api to check pump health status.
Index ¶
- Constants
- func LoadConfig(cfg string, defaultName string)
- func RequestShutdown() bool
- func ServeHealthCheck(healthPath string, healthAddress string)
- func SetupSignalHandler() <-chan struct{}
- type CertKey
- type CompletedConfig
- type Config
- type GenericAPIServer
- type InsecureServingInfo
- type JwtInfo
- type SecureServingInfo
Constants ¶
const ( // RecommendedHomeDir defines the default directory used to place all iam service configurations. RecommendedHomeDir = ".iam" // RecommendedEnvPrefix defines the ENV prefix used by all iam service. RecommendedEnvPrefix = "IAM" )
Variables ¶
This section is empty.
Functions ¶
func LoadConfig ¶
LoadConfig reads in config file and ENV variables if set.
func RequestShutdown ¶
func RequestShutdown() bool
RequestShutdown emulates a received event that is considered as shutdown signal (SIGTERM/SIGINT) This returns whether a handler was notified.
func ServeHealthCheck ¶ added in v1.4.0
ServeHealthCheck runs a http server used to provide a api to check pump health status.
func SetupSignalHandler ¶
func SetupSignalHandler() <-chan struct{}
SetupSignalHandler registered for SIGTERM and SIGINT. A stop channel is returned which is closed on one of these signals. If a second signal is caught, the program is terminated with exit code 1.
Types ¶
type CertKey ¶
type CertKey struct { // CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain CertFile string // KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile KeyFile string }
CertKey contains configuration items related to certificate.
type CompletedConfig ¶
type CompletedConfig struct {
*Config
}
CompletedConfig is the completed configuration for GenericAPIServer.
func (CompletedConfig) New ¶
func (c CompletedConfig) New() (*GenericAPIServer, error)
New returns a new instance of GenericAPIServer from the given config.
type Config ¶
type Config struct { SecureServing *SecureServingInfo InsecureServing *InsecureServingInfo Jwt *JwtInfo Mode string Middlewares []string Healthz bool EnableProfiling bool EnableMetrics bool }
Config is a structure used to configure a GenericAPIServer. Its members are sorted roughly in order of importance for composers.
func NewConfig ¶
func NewConfig() *Config
NewConfig returns a Config struct with the default values.
func (*Config) Complete ¶
func (c *Config) Complete() CompletedConfig
Complete fills in any fields not set that are required to have valid data and can be derived from other fields. If you're going to `ApplyOptions`, do that first. It's mutating the receiver.
type GenericAPIServer ¶
type GenericAPIServer struct { // SecureServingInfo holds configuration of the TLS server. SecureServingInfo *SecureServingInfo // InsecureServingInfo holds configuration of the insecure HTTP server. InsecureServingInfo *InsecureServingInfo // ShutdownTimeout is the timeout used for server shutdown. This specifies the timeout before server // gracefully shutdown returns. ShutdownTimeout time.Duration *gin.Engine // contains filtered or unexported fields }
GenericAPIServer contains state for a iam api server. type GenericAPIServer gin.Engine.
func (*GenericAPIServer) Close ¶
func (s *GenericAPIServer) Close()
Close graceful shutdown the api server.
func (*GenericAPIServer) InstallAPIs ¶
func (s *GenericAPIServer) InstallAPIs()
InstallAPIs install generic apis.
func (*GenericAPIServer) InstallMiddlewares ¶
func (s *GenericAPIServer) InstallMiddlewares()
InstallMiddlewares install generic middlewares.
func (*GenericAPIServer) Run ¶
func (s *GenericAPIServer) Run() error
Run spawns the http server. It only returns when the port cannot be listened on initially.
func (*GenericAPIServer) Setup ¶
func (s *GenericAPIServer) Setup()
Setup do some setup work for gin engine.
type InsecureServingInfo ¶
type InsecureServingInfo struct {
Address string
}
InsecureServingInfo holds configuration of the insecure http server.
type JwtInfo ¶
type JwtInfo struct { // defaults to "iam jwt" Realm string // defaults to empty Key string // defaults to one hour Timeout time.Duration // defaults to zero MaxRefresh time.Duration }
JwtInfo defines jwt fields used to create jwt authentication middleware.
type SecureServingInfo ¶
SecureServingInfo holds configuration of the TLS server.
func (*SecureServingInfo) Address ¶
func (s *SecureServingInfo) Address() string
Address join host IP address and host port number into a address string, like: 0.0.0.0:8443.