config

package
v1.4.21 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(configFile string, fs ...func()) error

func Set

func Set(conf *Config)

func Show

func Show(hiddenFields ...string) string

Types

type App

type App struct {
	CacheType             string  `yaml:"cacheType" json:"cacheType"`
	EnableCircuitBreaker  bool    `yaml:"enableCircuitBreaker" json:"enableCircuitBreaker"`
	EnableHTTPProfile     bool    `yaml:"enableHTTPProfile" json:"enableHTTPProfile"`
	EnableLimit           bool    `yaml:"enableLimit" json:"enableLimit"`
	EnableMetrics         bool    `yaml:"enableMetrics" json:"enableMetrics"`
	EnableStat            bool    `yaml:"enableStat" json:"enableStat"`
	EnableTrace           bool    `yaml:"enableTrace" json:"enableTrace"`
	Env                   string  `yaml:"env" json:"env"`
	Host                  string  `yaml:"host" json:"host"`
	MachineID             int     `yaml:"machineId" json:"machineId"`
	Name                  string  `yaml:"name" json:"name"`
	OpenCron              bool    `yaml:"openCron" json:"openCron"`
	OpenHTTP              bool    `yaml:"openHttp" json:"openHttp"`
	OpenJwt               bool    `yaml:"openJwt" json:"openJwt"`
	OpenSign              bool    `yaml:"openSign" json:"openSign"`
	OpenXSS               bool    `yaml:"openXSS" json:"openXSS"`
	RegistryDiscoveryType string  `yaml:"registryDiscoveryType" json:"registryDiscoveryType"`
	TracingSamplingRate   float64 `yaml:"tracingSamplingRate" json:"tracingSamplingRate"`
	Version               string  `yaml:"version" json:"version"`
}

type Args added in v1.3.23

type Args struct {
	XMessageTTL int `yaml:"xMessageTtl" json:"xMessageTtl"`
}

type Center

type Center struct {
	Nacos Nacos `yaml:"nacos" json:"nacos"`
}

func NewCenter

func NewCenter(configFile string) (*Center, error)

type ClientSecure

type ClientSecure struct {
	CaFile     string `yaml:"caFile" json:"caFile"`
	CertFile   string `yaml:"certFile" json:"certFile"`
	KeyFile    string `yaml:"keyFile" json:"keyFile"`
	ServerName string `yaml:"serverName" json:"serverName"`
	Type       string `yaml:"type" json:"type"`
}

type ClientToken

type ClientToken struct {
	AppID  string `yaml:"appID" json:"appID"`
	AppKey string `yaml:"appKey" json:"appKey"`
	Enable bool   `yaml:"enable" json:"enable"`
}

type Config

type Config struct {
	App           App           `yaml:"app" json:"app"`
	Database      Database      `yaml:"database" json:"database"`
	Elasticsearch Elasticsearch `yaml:"elasticsearch" json:"elasticsearch"`
	Etcd          Etcd          `yaml:"etcd" json:"etcd"`
	Grpc          Grpc          `yaml:"grpc" json:"grpc"`
	GrpcClient    []GrpcClient  `yaml:"grpcClient" json:"grpcClient"`
	HTTP          HTTP          `yaml:"http" json:"http"`
	Jaeger        Jaeger        `yaml:"jaeger" json:"jaeger"`
	Jwt           Jwt           `yaml:"jwt" json:"jwt"`
	Logger        Logger        `yaml:"logger" json:"logger"`
	Rabbitmq      Rabbitmq      `yaml:"rabbitmq" json:"rabbitmq"`
	Redis         Redis         `yaml:"redis" json:"redis"`
	Sentinel      Sentinel      `yaml:"sentinel" json:"sentinel"`
	Sign          Sign          `yaml:"sign" json:"sign"`
}

func Get

func Get() *Config

type ConsumerOption added in v1.3.23

type ConsumerOption struct {
	Consumer      string `yaml:"consumer" json:"consumer"`
	Exclusive     bool   `yaml:"exclusive" json:"exclusive"`
	Global        bool   `yaml:"global" json:"global"`
	IsAutoAck     bool   `yaml:"isAutoAck" json:"isAutoAck"`
	MsgDurable    bool   `yaml:"msgDurable" json:"msgDurable"`
	NoLocal       bool   `yaml:"noLocal" json:"noLocal"`
	NoWait        bool   `yaml:"noWait" json:"noWait"`
	PrefetchCount int    `yaml:"prefetchCount" json:"prefetchCount"`
	PrefetchSize  int    `yaml:"prefetchSize" json:"prefetchSize"`
}

type Database

type Database struct {
	Driver string `yaml:"driver" json:"driver"`
	Mysql  Mysql  `yaml:"mysql" json:"mysql"`
}

type DeadQueueBindOption added in v1.3.23

type DeadQueueBindOption struct {
	NoWait bool `yaml:"noWait" json:"noWait"`
}

type DeadQueueDeclareOption added in v1.3.23

type DeadQueueDeclareOption struct {
	Args       Args `yaml:"args" json:"args"`
	AutoDelete bool `yaml:"autoDelete" json:"autoDelete"`
	Durable    bool `yaml:"durable" json:"durable"`
	Exclusive  bool `yaml:"exclusive" json:"exclusive"`
	NoWait     bool `yaml:"noWait" json:"noWait"`
}

type DoingOrder added in v1.3.24

type DoingOrder struct {
	ConsumerNum              int                      `yaml:"consumerNum" json:"consumerNum"`
	ConsumerOption           ConsumerOption           `yaml:"consumerOption" json:"consumerOption"`
	DeadKey                  string                   `yaml:"deadKey" json:"deadKey"`
	DeadQueueBindOption      DeadQueueBindOption      `yaml:"deadQueueBindOption" json:"deadQueueBindOption"`
	DeadQueueDeclareOption   DeadQueueDeclareOption   `yaml:"deadQueueDeclareOption" json:"deadQueueDeclareOption"`
	DeadQueueName            string                   `yaml:"deadQueueName" json:"deadQueueName"`
	Enable                   bool                     `yaml:"enable" json:"enable"`
	ExchangeDeclareOptions   ExchangeDeclareOptions   `yaml:"exchangeDeclareOptions" json:"exchangeDeclareOptions"`
	ExchangeName             string                   `yaml:"exchangeName" json:"exchangeName"`
	NormalKey                string                   `yaml:"normalKey" json:"normalKey"`
	NormalQueueBindOption    DeadQueueBindOption      `yaml:"normalQueueBindOption" json:"normalQueueBindOption"`
	NormalQueueDeclareOption NormalQueueDeclareOption `yaml:"normalQueueDeclareOption" json:"normalQueueDeclareOption"`
	NormalQueueName          string                   `yaml:"normalQueueName" json:"normalQueueName"`
	QueueType                string                   `yaml:"queueType" json:"queueType"`
}

type Elasticsearch added in v1.3.12

type Elasticsearch struct {
	Addresses             []string `yaml:"addresses" json:"addresses"`
	APIKey                string   `yaml:"apiKey" json:"apiKey"`
	ConnectionKeepAlive   int      `yaml:"connectionKeepAlive" json:"connectionKeepAlive"`
	ConnectionTimeout     int      `yaml:"connectionTimeout" json:"connectionTimeout"`
	EnableHealthCheck     bool     `yaml:"enableHealthCheck" json:"enableHealthCheck"`
	EnablePingCheck       bool     `yaml:"enablePingCheck" json:"enablePingCheck"`
	ExpectContinueTimeout int      `yaml:"expectContinueTimeout" json:"expectContinueTimeout"`
	IdleConnTimeout       int      `yaml:"idleConnTimeout" json:"idleConnTimeout"`
	IsOpen                bool     `yaml:"isOpen" json:"isOpen"`
	MaxConnsPerHost       int      `yaml:"maxConnsPerHost" json:"maxConnsPerHost"`
	MaxIdleConns          int      `yaml:"maxIdleConns" json:"maxIdleConns"`
	MaxIdleConnsPerHost   int      `yaml:"maxIdleConnsPerHost" json:"maxIdleConnsPerHost"`
	MaxRetries            int      `yaml:"maxRetries" json:"maxRetries"`
	Password              string   `yaml:"password" json:"password"`
	ResponseHeaderTimeout int      `yaml:"responseHeaderTimeout" json:"responseHeaderTimeout"`
	RetryBackoff          int      `yaml:"retryBackoff" json:"retryBackoff"`
	RetryOnStatus         []int    `yaml:"retryOnStatus" json:"retryOnStatus"`
	Timeout               int      `yaml:"timeout" json:"timeout"`
	TLSHandshakeTimeout   int      `yaml:"tlsHandshakeTimeout" json:"tlsHandshakeTimeout"`
	Username              string   `yaml:"username" json:"username"`
}

type Etcd

type Etcd struct {
	Addrs []string `yaml:"addrs" json:"addrs"`
}

type ExchangeDeclareOptions added in v1.3.23

type ExchangeDeclareOptions struct {
	AutoDelete bool `yaml:"autoDelete" json:"autoDelete"`
	Durable    bool `yaml:"durable" json:"durable"`
	Internal   bool `yaml:"internal" json:"internal"`
	NoWait     bool `yaml:"noWait" json:"noWait"`
}

type Grpc

type Grpc struct {
	EnableToken  bool         `yaml:"enableToken" json:"enableToken"`
	HTTPPort     int          `yaml:"httpPort" json:"httpPort"`
	Port         int          `yaml:"port" json:"port"`
	ServerSecure ServerSecure `yaml:"serverSecure" json:"serverSecure"`
}

type GrpcClient

type GrpcClient struct {
	ClientSecure          ClientSecure `yaml:"clientSecure" json:"clientSecure"`
	ClientToken           ClientToken  `yaml:"clientToken" json:"clientToken"`
	EnableLoadBalance     bool         `yaml:"enableLoadBalance" json:"enableLoadBalance"`
	Host                  string       `yaml:"host" json:"host"`
	Name                  string       `yaml:"name" json:"name"`
	Port                  int          `yaml:"port" json:"port"`
	RegistryDiscoveryType string       `yaml:"registryDiscoveryType" json:"registryDiscoveryType"`
	Timeout               int          `yaml:"timeout" json:"timeout"`
}

type HTTP

type HTTP struct {
	Port    int `yaml:"port" json:"port"`
	Timeout int `yaml:"timeout" json:"timeout"`
}

type IgnoreMethods added in v1.1.67

type IgnoreMethods struct {
	Grpc []string `yaml:"grpc" json:"grpc"`
	HTTP []string `yaml:"http" json:"http"`
}

type Jaeger

type Jaeger struct {
	AgentHost string `yaml:"agentHost" json:"agentHost"`
	AgentPort int    `yaml:"agentPort" json:"agentPort"`
	Endpoint  string `yaml:"endpoint" json:"endpoint"`
}

type Jwt added in v1.0.2

type Jwt struct {
	Expire        int           `yaml:"expire" json:"expire"`
	IgnoreMethods IgnoreMethods `yaml:"ignoreMethods" json:"ignoreMethods"`
	Issuer        string        `yaml:"issuer" json:"issuer"`
	SigningKey    string        `yaml:"signingKey" json:"signingKey"`
	SigningMethod string        `yaml:"signingMethod" json:"signingMethod"`
}

type LogFileConfig added in v1.0.2

type LogFileConfig struct {
	Filename      string `yaml:"filename" json:"filename"`
	IsCompression bool   `yaml:"isCompression" json:"isCompression"`
	IsNoPrint     bool   `yaml:"isNoPrint" json:"isNoPrint"`
	IsSaveDay     bool   `yaml:"isSaveDay" json:"isSaveDay"`
	MaxAge        int    `yaml:"maxAge" json:"maxAge"`
	MaxBackups    int    `yaml:"maxBackups" json:"maxBackups"`
	MaxSize       int    `yaml:"maxSize" json:"maxSize"`
}

type Logger

type Logger struct {
	AsyncBufferSize    int           `yaml:"asyncBufferSize" json:"asyncBufferSize"`
	AsyncFlushInterval int           `yaml:"asyncFlushInterval" json:"asyncFlushInterval"`
	Format             string        `yaml:"format" json:"format"`
	IsAsync            bool          `yaml:"isAsync" json:"isAsync"`
	IsSave             bool          `yaml:"isSave" json:"isSave"`
	Level              string        `yaml:"level" json:"level"`
	LogFileConfig      LogFileConfig `yaml:"logFileConfig" json:"logFileConfig"`
	MaxLen             int           `yaml:"maxLen" json:"maxLen"`
}

type Mysql

type Mysql struct {
	ConnMaxLifetime      int      `yaml:"connMaxLifetime" json:"connMaxLifetime"`
	Dsn                  string   `yaml:"dsn" json:"dsn"`
	EnableLog            bool     `yaml:"enableLog" json:"enableLog"`
	MastersDsn           []string `yaml:"mastersDsn" json:"mastersDsn"`
	MaxIdleConns         int      `yaml:"maxIdleConns" json:"maxIdleConns"`
	MaxIdleTime          int      `yaml:"maxIdleTime" json:"maxIdleTime"`
	MaxOpenConns         int      `yaml:"maxOpenConns" json:"maxOpenConns"`
	SlavesDsn            []string `yaml:"slavesDsn" json:"slavesDsn"`
	SlowQueryThresholdMs int      `yaml:"slowQueryThresholdMs" json:"slowQueryThresholdMs"`
}

type Nacos

type Nacos struct {
	ContextPath string `yaml:"contextPath" json:"contextPath"`
	DataID      string `yaml:"dataID" json:"dataID"`
	Format      string `yaml:"format" json:"format"`
	Group       string `yaml:"group" json:"group"`
	IPAddr      string `yaml:"ipAddr" json:"ipAddr"`
	NamespaceID string `yaml:"namespaceID" json:"namespaceID"`
	Port        int    `yaml:"port" json:"port"`
	Scheme      string `yaml:"scheme" json:"scheme"`
}

type NormalQueueDeclareOption added in v1.3.23

type NormalQueueDeclareOption struct {
	AutoDelete bool `yaml:"autoDelete" json:"autoDelete"`
	Durable    bool `yaml:"durable" json:"durable"`
	Exclusive  bool `yaml:"exclusive" json:"exclusive"`
	NoWait     bool `yaml:"noWait" json:"noWait"`
}

type Pool added in v1.3.23

type Pool struct {
	AntsCap           int    `yaml:"antsCap" json:"antsCap"`
	DialTimeout       int    `yaml:"dialTimeout" json:"dialTimeout"`
	HealthCheckPeriod int    `yaml:"healthCheckPeriod" json:"healthCheckPeriod"`
	Heartbeat         int    `yaml:"heartbeat" json:"heartbeat"`
	InitialCap        int    `yaml:"initialCap" json:"initialCap"`
	MaxCap            int    `yaml:"maxCap" json:"maxCap"`
	MaxIdle           int    `yaml:"maxIdle" json:"maxIdle"`
	ReconnectTime     int    `yaml:"reconnectTime" json:"reconnectTime"`
	StatsLogOpen      bool   `yaml:"statsLogOpen" json:"statsLogOpen"`
	URL               string `yaml:"url" json:"url"`
}

type Rabbitmq added in v1.3.23

type Rabbitmq struct {
	DoingOrder DoingOrder `yaml:"DoingOrder" json:"DoingOrder"`
	Enable     bool       `yaml:"enable" json:"enable"`
	Pool       Pool       `yaml:"pool" json:"pool"`
}

type Redis

type Redis struct {
	DialTimeout  int    `yaml:"dialTimeout" json:"dialTimeout"`
	Dsn          string `yaml:"dsn" json:"dsn"`
	IdleTimeout  int    `yaml:"idleTimeout" json:"idleTimeout"`
	MaxConnAge   int    `yaml:"maxConnAge" json:"maxConnAge"`
	MinIdleConns int    `yaml:"minIdleConns" json:"minIdleConns"`
	PoolSize     int    `yaml:"poolSize" json:"poolSize"`
	PoolTimeout  int    `yaml:"poolTimeout" json:"poolTimeout"`
	ReadTimeout  int    `yaml:"readTimeout" json:"readTimeout"`
	WriteTimeout int    `yaml:"writeTimeout" json:"writeTimeout"`
}

type Rules added in v1.3.5

type Rules struct {
	Resource         string  `yaml:"resource" json:"resource"`
	StatIntervalInMs int     `yaml:"statIntervalInMs" json:"statIntervalInMs"`
	Threshold        float64 `yaml:"threshold" json:"threshold"`
}

type Sentinel added in v1.3.5

type Sentinel struct {
	Rules []Rules `yaml:"rules" json:"rules"`
}

type ServerSecure

type ServerSecure struct {
	CaFile   string `yaml:"caFile" json:"caFile"`
	CertFile string `yaml:"certFile" json:"certFile"`
	KeyFile  string `yaml:"keyFile" json:"keyFile"`
	Type     string `yaml:"type" json:"type"`
}

type Sign added in v1.0.2

type Sign struct {
	IgnoreUrls      IgnoreMethods `yaml:"ignoreUrls" json:"ignoreUrls"`
	SignExpiredTime int           `yaml:"signExpiredTime" json:"signExpiredTime"`
	SignKey         string        `yaml:"signKey" json:"signKey"`
}

Jump to

Keyboard shortcuts

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