options

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientCertAuthenticationOptions

type ClientCertAuthenticationOptions struct {
	// ClientCA is the certificate bundle for all the signers that you'll recognize for incoming client certificates
	ClientCA string `json:"client-ca-file" mapstructure:"client-ca-file"`
}

ClientCertAuthenticationOptions provides different options for client cert auth.

func NewClientCertAuthenticationOptions

func NewClientCertAuthenticationOptions() *ClientCertAuthenticationOptions

NewClientCertAuthenticationOptions creates a ClientCertAuthenticationOptions object with default parameters.

func (*ClientCertAuthenticationOptions) AddFlags

AddFlags adds flags related to ClientCertAuthenticationOptions for a specific server to the specified FlagSet.

func (*ClientCertAuthenticationOptions) Validate

func (o *ClientCertAuthenticationOptions) Validate() []error

Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.

type GRPCAclOptions

type GRPCAclOptions struct {
	Enabled       bool   `json:"enabled"        mapstructure:"enabled"`
	ConfigFile    string `json:"config_file"    mapstructure:"config-file"`
	DefaultPolicy string `json:"default_policy" mapstructure:"default-policy"`
}

GRPCAclOptions ACL 配置

type GRPCAuditOptions

type GRPCAuditOptions struct {
	Enabled bool `json:"enabled" mapstructure:"enabled"`
}

GRPCAuditOptions 审计配置

type GRPCAuthOptions

type GRPCAuthOptions struct {
	Enabled               bool          `json:"enabled"                mapstructure:"enabled"`
	EnableBearer          bool          `json:"enable_bearer"          mapstructure:"enable-bearer"`
	EnableHMAC            bool          `json:"enable_hmac"            mapstructure:"enable-hmac"`
	EnableAPIKey          bool          `json:"enable_api_key"         mapstructure:"enable-api-key"`
	HMACTimestampValidity time.Duration `json:"hmac_timestamp_validity" mapstructure:"hmac-timestamp-validity"`
	RequireIdentityMatch  bool          `json:"require_identity_match" mapstructure:"require-identity-match"`
}

GRPCAuthOptions 应用层认证配置

type GRPCConfig

type GRPCConfig struct {
	Addr        string // 服务器地址
	HealthzAddr string // 健康检查地址
	MTLS        GRPCMTLSOptions
	Auth        GRPCAuthOptions
	ACL         GRPCAclOptions
	Audit       GRPCAuditOptions
	TLSCertFile string
	TLSKeyFile  string
	Insecure    bool
}

GRPCConfig GRPC 服务器配置

type GRPCMTLSOptions

type GRPCMTLSOptions struct {
	Enabled           bool          `json:"enabled"             mapstructure:"enabled"`
	CAFile            string        `json:"ca_file"             mapstructure:"ca-file"`
	CADir             string        `json:"ca_dir"              mapstructure:"ca-dir"`
	CertFile          string        `json:"cert_file"           mapstructure:"cert-file"`
	KeyFile           string        `json:"key_file"            mapstructure:"key-file"`
	RequireClientCert bool          `json:"require_client_cert" mapstructure:"require-client-cert"`
	AllowedCNs        []string      `json:"allowed_cns"         mapstructure:"allowed-cns"`
	AllowedOUs        []string      `json:"allowed_ous"         mapstructure:"allowed-ous"`
	AllowedSANs       []string      `json:"allowed_sans"        mapstructure:"allowed-sans"`
	MinTLSVersion     string        `json:"min_tls_version"     mapstructure:"min-tls-version"`
	EnableAutoReload  bool          `json:"enable_auto_reload"  mapstructure:"enable-auto-reload"`
	ReloadInterval    time.Duration `json:"reload_interval"     mapstructure:"reload-interval"`
}

GRPCMTLSOptions mTLS 配置

type GRPCOptions

type GRPCOptions struct {
	BindAddress string            `json:"bind_address" mapstructure:"bind-address"` // 绑定地址
	BindPort    int               `json:"bind_port"    mapstructure:"bind-port"`    // 绑定端口
	HealthzPort int               `json:"healthz_port" mapstructure:"healthz-port"` // 健康检查端口
	MTLS        *GRPCMTLSOptions  `json:"mtls"         mapstructure:"mtls"`         // mTLS 选项
	Auth        *GRPCAuthOptions  `json:"auth"         mapstructure:"auth"`         // 应用层认证
	ACL         *GRPCAclOptions   `json:"acl"          mapstructure:"acl"`          // ACL
	Audit       *GRPCAuditOptions `json:"audit"        mapstructure:"audit"`        // 审计
	Insecure    bool              `json:"insecure"     mapstructure:"insecure"`     // 是否允许不安全(默认 true,启用 mTLS 时会强制为 false)
}

GRPCOptions GRPC 服务器配置选项

func NewGRPCOptions

func NewGRPCOptions() *GRPCOptions

NewGRPCOptions 创建默认的 GRPC 配置选项

func (*GRPCOptions) AddFlags

func (s *GRPCOptions) AddFlags(fs *pflag.FlagSet)

AddFlags 添加命令行参数

func (*GRPCOptions) ApplyTo

func (s *GRPCOptions) ApplyTo(c *GRPCConfig) error

ApplyTo 应用配置到服务器

func (*GRPCOptions) Validate

func (s *GRPCOptions) Validate() []error

Validate 验证GRPCOptions

type InsecureServingConfig

type InsecureServingConfig struct {
	Addr string // 服务器地址
}

InsecureServingConfig 不安全的服务器配置

type InsecureServingOptions

type InsecureServingOptions struct {
	BindAddress string `json:"bind_address" mapstructure:"bind-address"` // 绑定地址
	BindPort    int    `json:"bind_port"    mapstructure:"bind-port"`    // 绑定端口
}

InsecureServingOptions 不安全的服务器配置选项

func NewInsecureServingOptions

func NewInsecureServingOptions() *InsecureServingOptions

NewInsecureServingOptions 创建默认的不安全服务器配置选项

func (*InsecureServingOptions) AddFlags

func (s *InsecureServingOptions) AddFlags(fs *pflag.FlagSet)

AddFlags 添加命令行参数

func (*InsecureServingOptions) ApplyTo

func (s *InsecureServingOptions) ApplyTo(c *server.Config) error

ApplyTo 应用配置到服务器

func (*InsecureServingOptions) Validate

func (s *InsecureServingOptions) Validate() []error

Validate 验证InsecureServingOptions

type MigrationOptions

type MigrationOptions struct {
	Enabled  bool   `json:"enabled"  mapstructure:"enabled"`  // 是否启用自动迁移
	Database string `json:"database" mapstructure:"database"` // 数据库名称
}

MigrationOptions 数据库迁移配置选项

func NewMigrationOptions

func NewMigrationOptions() *MigrationOptions

NewMigrationOptions 创建默认的迁移选项

func (*MigrationOptions) AddFlags

func (o *MigrationOptions) AddFlags(fs *pflag.FlagSet)

AddFlags 添加命令行参数

func (*MigrationOptions) Validate

func (o *MigrationOptions) Validate() []error

Validate 验证选项

type MySQLOptions

type MySQLOptions struct {
	Host                  string        `json:"host,omitempty"                     mapstructure:"host"`
	Username              string        `json:"username,omitempty"                 mapstructure:"username"`
	Password              string        `json:"-"                                  mapstructure:"password"`
	Database              string        `json:"database"                           mapstructure:"database"`
	MaxIdleConnections    int           `json:"max-idle-connections,omitempty"     mapstructure:"max-idle-connections"`
	MaxOpenConnections    int           `json:"max-open-connections,omitempty"     mapstructure:"max-open-connections"`
	MaxConnectionLifeTime time.Duration `json:"max-connection-life-time,omitempty" mapstructure:"max-connection-life-time"`
	LogLevel              int           `json:"log-level"                          mapstructure:"log-level"`
}

MySQLOptions defines options for mysql database.

func NewMySQLOptions

func NewMySQLOptions() *MySQLOptions

NewMySQLOptions create a `zero` value instance.

func (*MySQLOptions) AddFlags

func (o *MySQLOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to mysql storage for a specific APIServer to the specified FlagSet.

func (*MySQLOptions) Validate

func (o *MySQLOptions) Validate() []error

Validate verifies flags passed to MySQLOptions.

type NSQOptions

type NSQOptions struct {
	// Enabled 是否启用 NSQ
	Enabled bool `json:"enabled" mapstructure:"enabled"`

	// LookupdAddrs NSQLookupd 地址列表
	LookupdAddrs []string `json:"lookupd-addrs" mapstructure:"lookupd-addrs"`

	// NSQdAddr NSQd 地址(用于发布)
	NSQdAddr string `json:"nsqd-addr" mapstructure:"nsqd-addr"`

	// MaxAttempts 最大消息重试次数
	MaxAttempts uint16 `json:"max-attempts" mapstructure:"max-attempts"`

	// MaxInFlight 最大消息处理并发数
	MaxInFlight int `json:"max-in-flight" mapstructure:"max-in-flight"`

	// MsgTimeout 消息超时时间(秒)
	MsgTimeout int `json:"msg-timeout" mapstructure:"msg-timeout"`

	// RequeueDelay 重新入队延迟(秒)
	RequeueDelay int `json:"requeue-delay" mapstructure:"requeue-delay"`
}

NSQOptions NSQ 消息队列配置选项

func NewNSQOptions

func NewNSQOptions() *NSQOptions

NewNSQOptions 创建默认的 NSQ 配置

func (*NSQOptions) AddFlags

func (o *NSQOptions) AddFlags(fs *pflag.FlagSet)

AddFlags 添加 NSQ 相关的命令行参数

func (*NSQOptions) ToMessagingConfig

func (o *NSQOptions) ToMessagingConfig() *messaging.Config

ToMessagingConfig 转换为 messaging.Config

func (*NSQOptions) Validate

func (o *NSQOptions) Validate() []error

Validate 验证 NSQ 配置

type RedisOptions

type RedisOptions struct {
	// Cache Redis - 用于缓存、会话、限流等临时数据
	Cache *SingleRedisOptions `json:"cache" mapstructure:"cache"`
}

RedisOptions defines options for a single redis instance (cache).

func NewRedisOptions

func NewRedisOptions() *RedisOptions

NewRedisOptions create a `zero` value instance.

func (*RedisOptions) AddFlags

func (o *RedisOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to redis storage for a specific APIServer to the specified FlagSet.

func (*RedisOptions) Validate

func (o *RedisOptions) Validate() []error

Validate verifies flags passed to RedisOptions.

type SecureServingConfig

type SecureServingConfig struct {
	Addr     string // 服务器地址
	CertFile string // 证书文件
	KeyFile  string // 密钥文件
}

SecureServingConfig 安全的服务器配置

type SecureServingOptions

type SecureServingOptions struct {
	BindAddress string `json:"bind_address" mapstructure:"bind-address"` // 绑定地址
	BindPort    int    `json:"bind_port"    mapstructure:"bind-port"`    // 绑定端口
	TLS         struct {
		CertFile string `json:"cert_file"    mapstructure:"cert-file"`        // 证书文件
		KeyFile  string `json:"key_file"     mapstructure:"private-key-file"` // 密钥文件
	} `json:"tls" mapstructure:"tls"`
}

SecureServingOptions 安全的服务器配置选项

func NewSecureServingOptions

func NewSecureServingOptions() *SecureServingOptions

NewSecureServingOptions 创建默认的安全服务器配置选项

func (*SecureServingOptions) AddFlags

func (s *SecureServingOptions) AddFlags(fs *pflag.FlagSet)

AddFlags 添加命令行参数

func (*SecureServingOptions) ApplyTo

func (s *SecureServingOptions) ApplyTo(c *server.Config) error

ApplyTo 应用配置到服务器

func (*SecureServingOptions) Complete

func (s *SecureServingOptions) Complete() error

Complete 完成配置选项

func (*SecureServingOptions) Validate

func (s *SecureServingOptions) Validate() []error

Validate 验证SecureServingOptions

type ServerConfig

type ServerConfig struct {
	Insecure *InsecureServingConfig // 不安全服务器配置
	Secure   *SecureServingConfig   // 安全服务器配置
	GRPC     *GRPCConfig            // GRPC 服务器配置
}

ServerConfig 服务器配置

type ServerRunOptions

type ServerRunOptions struct {
	Mode                 string   `json:"mode" mapstructure:"mode"`
	Healthz              bool     `json:"healthz" mapstructure:"healthz"`
	Middlewares          []string `json:"middlewares" mapstructure:"middlewares"`
	AllowDegradedStartup bool     `json:"allowDegradedStartup" mapstructure:"allow-degraded-startup"`
}

ServerRunOptions 在运行的通用服务器选项

func NewServerRunOptions

func NewServerRunOptions() *ServerRunOptions

NewServerRunOptions 简单工厂方法,创建在运行的服务器选项

func (*ServerRunOptions) AddFlags

func (s *ServerRunOptions) AddFlags(fs *pflag.FlagSet)

AddFlags 为特定的 APIServer 添加标志到指定的 FlagSet

func (*ServerRunOptions) ApplyTo

func (s *ServerRunOptions) ApplyTo(c *server.Config) error

ApplyTo 将运行选项应用到方法接收者并返回自身

func (*ServerRunOptions) Validate

func (s *ServerRunOptions) Validate() []error

Validate 检查 ServerRunOptions 的验证

type SingleRedisOptions

type SingleRedisOptions struct {
	Host                  string   `json:"host,omitempty"                         mapstructure:"host"`
	Port                  int      `json:"port,omitempty"                         mapstructure:"port"`
	Addrs                 []string `json:"addrs,omitempty"                        mapstructure:"addrs"`
	Username              string   `json:"username,omitempty"                     mapstructure:"username"`
	Password              string   `json:"-"                                      mapstructure:"password"`
	Database              int      `json:"database"                               mapstructure:"database"`
	MaxIdle               int      `json:"max-idle,omitempty"                     mapstructure:"max-idle"`
	MaxActive             int      `json:"max-active,omitempty"                   mapstructure:"max-active"`
	Timeout               int      `json:"timeout,omitempty"                      mapstructure:"timeout"`
	MinIdleConns          int      `json:"min-idle-conns,omitempty"               mapstructure:"min-idle-conns"`
	PoolTimeout           int      `json:"pool-timeout,omitempty"                 mapstructure:"pool-timeout"`
	DialTimeout           int      `json:"dial-timeout,omitempty"                 mapstructure:"dial-timeout"`
	ReadTimeout           int      `json:"read-timeout,omitempty"                 mapstructure:"read-timeout"`
	WriteTimeout          int      `json:"write-timeout,omitempty"                mapstructure:"write-timeout"`
	EnableCluster         bool     `json:"enable-cluster,omitempty"               mapstructure:"enable-cluster"`
	UseSSL                bool     `json:"use-ssl,omitempty"                      mapstructure:"use-ssl"`
	SSLInsecureSkipVerify bool     `json:"ssl-insecure-skip-verify,omitempty"     mapstructure:"ssl-insecure-skip-verify"`
	EnableLogging         bool     `json:"enable-logging,omitempty"               mapstructure:"enable-logging"`
}

SingleRedisOptions defines options for a single redis instance.

Jump to

Keyboard shortcuts

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