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 GenerateCertsForHostname(host string, rootCA *tls.Certificate, certPath, privateKeyPath string) (*tls.Certificate, error)
- func GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
- func GetSubject(host string) pkix.Name
- func GetTlsConfig(rootCA CertKey) *tls.Config
- func LoadCertificate(host, certPath, privkeyPath string) (*tls.Certificate, error)
- func LoadConfig(cfg string, defaultName string)
- func RequestShutdown() bool
- func ServeHealthCheck(healthPath string, healthAddress string)
- func SetupSignalHandler() <-chan struct{}
- type CertKey
- type CertsCache
- type Cluster
- type CompletedConfig
- type Config
- type GenericProxyServer
- func (s *GenericProxyServer) Close()
- func (s *GenericProxyServer) GetMachineId() error
- func (s *GenericProxyServer) InstallAPIs()
- func (s *GenericProxyServer) InstallMiddlewares()
- func (s *GenericProxyServer) InstallPlugins()
- func (s *GenericProxyServer) Run() error
- func (s *GenericProxyServer) Setup()
- type InsecureServingInfo
- type JwtInfo
- type SecureServingInfo
Constants ¶
const ( // RecommendedHomeDir defines the default directory used to place all iam service configurations. RecommendedHomeDir = ".pigpig" // RecommendedEnvPrefix defines the ENV prefix used by all iam service. RecommendedEnvPrefix = "PigPig" )
const RedisKeyPrefix = "pigpig-service-discover-"
RedisKeyPrefix redis keys uniform prefix.
Variables ¶
This section is empty.
Functions ¶
func GenerateCertsForHostname ¶
func GenerateCertsForHostname(host string, rootCA *tls.Certificate, certPath, privateKeyPath string) (*tls.Certificate, error)
GenerateCertsForHostname base on hostname, root CA, certPath and privateKeyPath return tls.Certificate.
func GetCertificate ¶
func GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)
GetCertificate defines tls.GetCertificate operation.
func GetSubject ¶
GetSubject base on hostname return certificate subject.
func GetTlsConfig ¶
GetTlsConfig initialize tlsconfig must provided a rootCA by the calls.
func LoadCertificate ¶
func LoadCertificate(host, certPath, privkeyPath string) (*tls.Certificate, error)
LoadCertificate according to host, cert-path and private-key-path then return tls.Certificate.
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 ¶
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 CertsCache ¶
type CertsCache struct { CacheMap map[string]*tls.Certificate RootCa CertKey // contains filtered or unexported fields }
CertsCache certificate cache.
type Cluster ¶
type Cluster struct { Enable bool Role string IsMasterHandle bool // Name is this cluster name Name string ClusterId string // LoadPolicy the current can choose load-balance policy when the role is master LoadPolicy string }
Cluster contains configuration items related to cluster.
type CompletedConfig ¶
type CompletedConfig struct {
*Config
}
CompletedConfig is the completed configuration for GenericAPIServer.
func (CompletedConfig) New ¶
func (c CompletedConfig) New() (*GenericProxyServer, error)
New returns a new instance of GenericAPIServer from the given config.
type Config ¶
type Config struct { SecureServing *SecureServingInfo InsecureServing *InsecureServingInfo Middlewares []string Healthz bool EnableProfiling bool EnableMetrics bool Plugins []string Cluster dudu.Cluster }
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 GenericProxyServer ¶
type GenericProxyServer 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 Cluster dudu.Cluster DistributedNode *infoutil.DistributedId MachineId int64 LocalNetIFAddr string Engine *dudu.ProxyHttpMux // contains filtered or unexported fields }
GenericProxyServer contains state for an iam api server. type GenericProxyServer gin.Engine.
func (*GenericProxyServer) Close ¶
func (s *GenericProxyServer) Close()
Close graceful shutdown the api server.
func (*GenericProxyServer) GetMachineId ¶
func (s *GenericProxyServer) GetMachineId() error
GetMachineId get current server machine id.
func (*GenericProxyServer) InstallAPIs ¶
func (s *GenericProxyServer) InstallAPIs()
InstallAPIs install generic apis.
func (*GenericProxyServer) InstallMiddlewares ¶
func (s *GenericProxyServer) InstallMiddlewares()
InstallMiddlewares install generic middlewares.
func (*GenericProxyServer) InstallPlugins ¶
func (s *GenericProxyServer) InstallPlugins()
InstallPlugins install plugin.md.
func (*GenericProxyServer) Run ¶
func (s *GenericProxyServer) Run() error
Run spawns the http server. It only returns when the port cannot be listened on initially.
func (*GenericProxyServer) Setup ¶
func (s *GenericProxyServer) Setup()
Setup do some setup work for gin transport.
type InsecureServingInfo ¶
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.