server

package
v3.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package server 定义了所有平台通用的通用 apiserver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertKey

type CertKey struct {
	// CertFile 包含 PEM 编码的证书,可能包含完整的证书链
	CertFile string
	// KeyFile 包含 PEM 编码的证书的私钥
	KeyFile string
}

CertKey contains configuration items related to certificate. 包含与证书相关的配置项

type CompletedConfig

type CompletedConfig struct {
	*Config
}

CompletedConfig 是 GenericAPIServer 的完成配置

func (CompletedConfig) New

New 从给定的配置创建一个新的 GenericAPIServer 实例

type Config

type Config struct {
	SecureServing   *SecureServingInfo
	InsecureServing *InsecureServingInfo
	Jwt             *JwtInfo
	Mode            string
	Middlewares     []string
	Healthz         bool
	EnableProfiling bool
	EnableMetrics   bool
}

Config 是用于配置 GenericAPIServer 的结构体 其成员按重要性排序

func NewConfig

func NewConfig() *Config

NewConfig 返回一个包含默认值的 Config 结构体

func (*Config) Complete

func (c *Config) Complete() CompletedConfig

Complete 填充任何未设置的字段,这些字段是必需的,并且可以从其他字段派生出来 如果需要 `ApplyOptions`,请先执行该操作。它正在修改接收者。

type Environment

type Environment string

Environment is the application environment derived from RuntimeMode.

const (
	EnvironmentDevelopment Environment = "development"
	EnvironmentTest        Environment = "test"
	EnvironmentProduction  Environment = "production"
)

type GenericAPIServer

type GenericAPIServer struct {
	SecureServingInfo   *SecureServingInfo
	InsecureServingInfo *InsecureServingInfo
	ShutdownTimeout     time.Duration
	*gin.Engine
	// contains filtered or unexported fields
}

GenericAPIServer 定义通用 API 服务器

func (*GenericAPIServer) Close

func (s *GenericAPIServer) Close()

Close 关闭 HTTP 服务器

func (*GenericAPIServer) InstallAPIs

func (s *GenericAPIServer) InstallAPIs()

InstallAPIs 安装通用 API

func (*GenericAPIServer) InstallMiddlewares

func (s *GenericAPIServer) InstallMiddlewares()

InstallMiddlewares 安装中间件

func (*GenericAPIServer) Run

func (s *GenericAPIServer) Run() error

Run 启动 HTTP 服务器

func (*GenericAPIServer) Setup

func (s *GenericAPIServer) Setup()

Setup 设置通用 API 服务器

type InsecureServingInfo

type InsecureServingInfo struct {
	Address string
}

InsecureServingInfo 包含不安全 HTTP 服务器的配置信息

type JwtInfo

type JwtInfo struct {
	// Realm 默认值为 "iam jwt"
	Realm string
	// Key 默认值为空
	Key string
	// Timeout 默认值为一小时
	Timeout time.Duration
	// MaxRefresh 默认值为零
	MaxRefresh time.Duration
}

JwtInfo 定义了用于创建 JWT 认证中间件的 JWT 字段

type RuntimeMode

type RuntimeMode string

RuntimeMode is the canonical Gin server mode accepted by iam-apiserver.

const (
	RuntimeModeDebug   RuntimeMode = "debug"
	RuntimeModeTest    RuntimeMode = "test"
	RuntimeModeRelease RuntimeMode = "release"
)

type RuntimeProfile

type RuntimeProfile struct {
	ServerMode  RuntimeMode
	Environment Environment
}

RuntimeProfile is the single resolved runtime-mode truth shared by bootstrap and downstream modules.

func ResolveRuntimeProfile

func ResolveRuntimeProfile(raw string) (RuntimeProfile, error)

ResolveRuntimeProfile normalizes and validates the configured server mode.

func (RuntimeProfile) AllowsDegraded

func (p RuntimeProfile) AllowsDegraded(requested bool) bool

AllowsDegraded applies the production invariant to an explicit degraded startup request.

func (RuntimeProfile) IsDevelopment

func (p RuntimeProfile) IsDevelopment() bool

IsDevelopment reports whether development-only fallbacks may apply.

func (RuntimeProfile) IsProductionLike

func (p RuntimeProfile) IsProductionLike() bool

IsProductionLike reports whether production safety rules must apply.

type SecureServingInfo

type SecureServingInfo struct {
	// BindAddress 绑定地址
	BindAddress string
	// BindPort 绑定端口
	BindPort int
	// CertKey 包含证书和私钥的配置
	CertKey CertKey
}

包含 TLS 服务器的配置信息

func (*SecureServingInfo) Address

func (s *SecureServingInfo) Address() string

Address 将主机 IP 地址和主机端口号连接成一个地址字符串,例如:0.0.0.0:8443

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL