options

package
v0.0.0-...-c820190 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const TracerNameNoGinCtx = "custom-srv"

Variables

This section is empty.

Functions

This section is empty.

Types

type GORMUser

type GORMUser interface {
	// Get the new session
	DB() *gorm.DB
}

type JwtOptions

type JwtOptions struct {
	// 底层使用的 github.com/appleboy/gin-jwt/v2 包中需要的参数
	Realm      string        `json:"realm"       mapstructure:"realm"`       // Realm name to display to the user.
	Key        string        `json:"key"         mapstructure:"key"`         // Private key used to sign jwt token.
	Timeout    time.Duration `json:"timeout"     mapstructure:"timeout"`     // JWT token timeout.
	MaxRefresh time.Duration `json:"max-refresh" mapstructure:"max-refresh"` // This field allows clients to refresh their token until MaxRefresh has passed.
}

func NewJwtOptions

func NewJwtOptions() *JwtOptions

func (*JwtOptions) AddFlags

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

func (*JwtOptions) Validate

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

type MySQLOptions

type MySQLOptions struct {
	Host     string `json:"host,omitempty" mapstructure:"host,omitempty"`
	Port     string `json:"port,omitempty" mapstructure:"port,omitempty"`
	Username string `json:"username,omitempty" mapstructure:"username,omitempty"`
	Password string `json:"password,omitempty" mapstructure:"password,omitempty"`
	Database string `json:"database" mapstructure:"database"`
	LogLevel int    `json:"log-level,omitempty" mapstructure:"log-level,omitempty"`
	//连接池会用到
	MaxIdleConnections    int           `json:"max-idle-connections,omitempty" mapstructure:"max-idle-connections,omitempty"`
	MaxConnectionLifetime time.Duration `json:"max-connection-lifetime,omitempty" mapstructure:"max-connection-lifetime,omitempty"`
	MaxOpenConnections    int           `json:"max-open-connections,omitempty" mapstructure:"max-open-connections,omitempty"`
}

func NewMySQLOptions

func NewMySQLOptions() *MySQLOptions

func (*MySQLOptions) AddFlags

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

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

func (*MySQLOptions) Validate

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

Validate verifies flags passed to ServerOptions.

type RedisOptions

type RedisOptions struct {
	Host                  string   `mapstructure:"host" json:"host"`
	Port                  int      `mapstructure:"port" json:"port"`
	Addrs                 []string `mapstructure:"addrs" json:"addrs"`
	Username              string   `mapstructure:"username" json:"username"`
	Password              string   `mapstructure:"password" json:"password"`
	Database              int      `mapstructure:"database" json:"database"`
	MasterName            string   `mapstructure:"master-name" json:"master-name"`
	MaxIdle               int      `mapstructure:"optimisation-max-idle" json:"optimisation-max-idle"`
	MaxActive             int      `mapstructure:"optimisation-max-active" json:"optimisation-max-active"`
	Timeout               int      `mapstructure:"timeout" json:"timeout"`
	EnableCluster         bool     `mapstructure:"enable-cluster" json:"enable-cluster"`
	UseSSL                bool     `mapstructure:"use-ssl" json:"use-ssl"`
	SSLInsecureSkipVerify bool     `mapstructure:"ssl-insecure-skip-verify" json:"ssl-insecure-skip-verify"`
	EnableTracing         bool     `mapstructure:"enabletracing" json:"enabletracing"`
}

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

type RegistryOptions

type RegistryOptions struct {
	Address string `json:"address" mapstructure:"address,omitempty"`
	// 指明基于什么进行注册 如:nacos consul etcd等,因为不通的注册中心 可能使用 http tcp grpc 等不同的协议
	Scheme string `json:"scheme" mapstructure:"scheme,omitempty"`
}

RegistryOptions registry center options console, etcd, nacos etc.

func NewRegistryOptions

func NewRegistryOptions() *RegistryOptions

NewRegistryOptions 创建一个默认注册中心的配置

func (*RegistryOptions) AddFlags

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

AddFlags 将配置信息添加到 FlagSet 中

func (*RegistryOptions) Validate

func (o *RegistryOptions) Validate() (errs []error)

Validate 校验配置是否正确

type ServerOptions

type ServerOptions struct {
	Name              string   `json:"name,omitempty" mapstructure:"name"`                 // 服务名称
	Host              string   `json:"host,omitempty" mapstructure:"host"`                 // 服务地址
	Port              int      `json:"port,omitempty" mapstructure:"port"`                 // 服务端口
	HttpPort          int      `json:"http_port,omitempty" mapstructure:"http_port"`       // http端口
	EnableProfiling   bool     `json:"profiling,omitempty" mapstructure:"profiling"`       // 是否开启性能分析
	EnableLimit       bool     `json:"limit,omitempty" mapstructure:"limit"`               // 是否开启限流
	EnableMetrics     bool     `json:"metrics,omitempty" mapstructure:"metrics"`           // 是否开启指标
	EnableHealthCheck bool     `json:"health_check,omitempty" mapstructure:"health_check"` // 是否开启健康检查
	Middlewares       []string `json:"middlewares,omitempty" mapstructure:"middlewares"`   // 中间件
}

ServerOptions service discovery center options console, etcd, nacos etc.

func NewServerOptions

func NewServerOptions() *ServerOptions

func (*ServerOptions) AddFlags

func (so *ServerOptions) AddFlags(fs *pflag.FlagSet)

func (*ServerOptions) Validate

func (so *ServerOptions) Validate() (errs []error)

type SmsOptions

type SmsOptions struct {
	APIKey    string `json:"key" mapstructure:"key"`
	APISecret string `json:"secret" mapstructure:"secret"`
}

func NewSmsOptions

func NewSmsOptions() *SmsOptions

func (*SmsOptions) AddFlags

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

func (*SmsOptions) Validate

func (so *SmsOptions) Validate() []error

type TelemetryOptions

type TelemetryOptions struct {
	// Name is the name of the service.
	Name string `json:"name"`
	// 连接地址
	Endpoint string `json:"endpoint"`
	// SampleRate is the rate at which traces are sampled. 1.0 means all traces are sampled, 0.0 means no traces are sampled.
	// 意思是采样率,1.0表示所有的都采样,0.0表示不采样
	Sampler float64 `json:"sampler"`
	// Batcher is the type of batcher to use for sending traces to the collector.
	// Batcher是用于将跟踪发送到收集器的批处理程序类型。
	Batcher string `json:"batcher"`
}

func NewTelemetryOptions

func NewTelemetryOptions() *TelemetryOptions

func (*TelemetryOptions) AddFlags

func (t *TelemetryOptions) AddFlags(fs *pflag.FlagSet)

func (*TelemetryOptions) Validate

func (t *TelemetryOptions) Validate() (errs []error)

Jump to

Keyboard shortcuts

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