options

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertKey

type CertKey struct {
	CertFile string `json:"cert-file"        mapstructure:"cert-file"`        // 证书文件
	KeyFile  string `json:"private-key-file" mapstructure:"private-key-file"` // 私钥文件
}

CertKey 包含了证书和私钥.

type GeneratedKeyCert

type GeneratedKeyCert struct {
	CertKey       CertKey `json:"cert-key"  mapstructure:"cert-key"`  // 支持显式指定证书和私钥
	CertDirectory string  `json:"cert-dir"  mapstructure:"cert-dir"`  // 未设置证书和私钥时会在此目录生成
	PairName      string  `json:"pair-name" mapstructure:"pair-name"` // 生成证书和私钥的文件名
}

GeneratedKeyCert 包含了证书相关配置.

type InsecureServingOptions

type InsecureServingOptions struct {
	BindAddress string `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int    `json:"bind-port"    mapstructure:"bind-port"`
}

InsecureServingOptions 定义了 HTTP 服务配置,无需认证、鉴权.

func NewInsecureServingOptions

func NewInsecureServingOptions() *InsecureServingOptions

NewInsecureServingOptions 创建了一个默认 HTTP 服务配置.

func (*InsecureServingOptions) AddFlags

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

AddFlags 向指定 FlagSet 中添加 HTTP 选项相关标志.

func (*InsecureServingOptions) ApplyTo

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

ApplyTo 将当前选项绑定到 Config 中.

func (*InsecureServingOptions) Validate

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

Validate 验证 HTTP 选项.

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 定义了 MySQL 数据库的选项.

func NewMySQLOptions

func NewMySQLOptions() *MySQLOptions

NewMySQLOptions 创建一个默认值的 MySQL 选项实例.

func (*MySQLOptions) AddFlags

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

AddFlags 向指定 FlagSet 中添加 MySQL 选项相关标志.

func (*MySQLOptions) Validate

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

Validate 验证 MySQL 选项.

type RedisOptions

type RedisOptions struct {
	Host     string `json:"host"     mapstructure:"host"`
	Port     int    `json:"port"     mapstructure:"port"`
	Username string `json:"username" mapstructure:"username"`
	Password string `json:"password" mapstructure:"password"`
	Database int    `json:"database" mapstructure:"database"`
}

RedisOptions 定义了 Redis 选项.

func NewRedisOptions

func NewRedisOptions() *RedisOptions

NewRedisOptions 创建一个默认值的 Redis 选项实例.

func (*RedisOptions) AddFlags

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

AddFlags 向指定 FlagSet 中添加 Redis 选项相关标志.

func (*RedisOptions) Validate

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

Validate 验证 Redis 选项.

type SecureServingOptions

type SecureServingOptions struct {
	BindAddress string           `json:"bind-address" mapstructure:"bind-address"`
	BindPort    int              `json:"bind-port"    mapstructure:"bind-port"`
	ServerCert  GeneratedKeyCert `json:"tls"          mapstructure:"tls"`
	RequirePort bool
}

SecureServingOptions 定义了 HTTPS 服务配置.

func NewSecureServingOptions

func NewSecureServingOptions() *SecureServingOptions

NewSecureServingOptions 创建了一个默认 HTTPS 服务配置.

func (*SecureServingOptions) AddFlags

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

AddFlags 向指定 FlagSet 中添加 HTTPS 选项相关标志.

func (*SecureServingOptions) ApplyTo

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

ApplyTo 将当前选项绑定到 Config 中.

func (*SecureServingOptions) Complete

func (s *SecureServingOptions) Complete() error

Complete 填写所有需要有效数据但未设置的字段.

func (*SecureServingOptions) Validate

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

Validate 验证 HTTPS 选项.

type ServerRunOptions

type ServerRunOptions struct {
	Mode        string   `json:"mode"        mapstructure:"mode"`
	Healthz     bool     `json:"healthz"     mapstructure:"healthz"`
	Middlewares []string `json:"middlewares" mapstructure:"middlewares"`
}

ServerRunOptions 定义了一个通用 API 服务器配置.

func NewServerRunOptions

func NewServerRunOptions() *ServerRunOptions

NewServerRunOptions 创建了一个默认服务器配置.

func (*ServerRunOptions) AddFlags

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

AddFlags 向指定 FlagSet 中添加服务器选项相关标志.

func (*ServerRunOptions) ApplyTo

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

ApplyTo 将当前选项绑定到 Config 中.

func (*ServerRunOptions) Validate

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

Validate 验证服务器选项.

Jump to

Keyboard shortcuts

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