Documentation ¶
Index ¶
- Variables
- func GetRedisClient() *redis.Client
- func SetRedisClient(c *redis.Client)
- func Setup(configFile string, fs ...func())
- type AliyunOSS
- type AliyunSMS
- type Application
- type AwsS3
- type Cache
- type Config
- type DBResolverConfig
- type Database
- type Email
- type Entra
- type File
- type Jwt
- type Local
- type Locker
- type Logger
- type Mock
- type NSQOptions
- type Oss
- type Qiniu
- type Queue
- type QueueMemory
- type QueueNSQ
- type QueueRedis
- type RedisConnectOptions
- type Settings
- type Sms
- type Smtp
- type Ssl
- type TencentCOS
- type Tls
Constants ¶
This section is empty.
Variables ¶
View Source
var ApplicationConfig = new(Application)
View Source
var CacheConfig = new(Cache)
CacheConfig cache配置
View Source
var (
DatabaseConfig = new(Database)
)
View Source
var EmailConfig = new(Email)
View Source
var EntraConfig = new(Entra)
View Source
var (
ExtendConfig interface{}
)
View Source
var FileConfig = new(File)
View Source
var JwtConfig = new(Jwt)
View Source
var LockerConfig = new(Locker)
View Source
var LoggerConfig = new(Logger)
View Source
var OssConfig = new(Oss)
View Source
var QueueConfig = new(Queue)
View Source
var SmsConfig = new(Sms)
View Source
var SslConfig = new(Ssl)
Functions ¶
Types ¶
type AliyunOSS ¶ added in v1.0.20
type AliyunOSS struct { Endpoint string `mapstructure:"endpoint" json:"endpoint" yaml:"endpoint"` AccessKeyId string `mapstructure:"access-key-id" json:"accessKeyId" yaml:"access-key-id"` AccessKeySecret string `mapstructure:"access-key-secret" json:"accessKeySecret" yaml:"access-key-secret"` BucketName string `mapstructure:"bucket-name" json:"bucketName" yaml:"bucket-name"` BucketUrl string `mapstructure:"bucket-url" json:"bucketUrl" yaml:"bucket-url"` }
type Application ¶
type AwsS3 ¶ added in v1.0.32
type AwsS3 struct { Region string `mapstructure:"region" json:"region" yaml:"region"` AccessKeyId string `mapstructure:"access-key-id" json:"accessKeyId" yaml:"access-key-id"` AccessKeySecret string `mapstructure:"access-key-secret" json:"accessKeySecret" yaml:"access-key-secret"` BucketName string `mapstructure:"bucket-name" json:"bucketName" yaml:"bucket-name"` }
type Cache ¶
type Cache struct { Redis *RedisConnectOptions Memory interface{} }
type Config ¶
type Config struct { Application *Application `yaml:"application"` Ssl *Ssl `yaml:"ssl"` Logger *Logger `yaml:"logger"` Jwt *Jwt `yaml:"jwt"` Database *Database `yaml:"database"` Cache *Cache `yaml:"cache"` Queue *Queue `yaml:"queue"` Locker *Locker `yaml:"locker"` Oss *Oss `yaml:"oss"` Sms *Sms `yaml:"sms"` File *File `yaml:"file"` Email *Email `yaml:"email"` Entra *Entra `yaml:"entra"` }
Config 配置集合
type DBResolverConfig ¶
type Local ¶ added in v1.0.20
type Local struct {
Path string `mapstructure:"path" json:"path" yaml:"path"` // 本地文件路径
}
type Locker ¶
type Locker struct {
Redis *RedisConnectOptions
}
type Logger ¶
type Logger struct { Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别 Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出 File string `mapstructure:"file" json:"file" yaml:"file"` // 日志文件 URL string `mapstructure:"url" json:"url" yaml:"url"` // url that will be processed by sink in the zap Output string `mapstructure:"output" json:"output" yaml:"output"` // possible values: stdout|stderr|file combine multiple values with '+' Labels string `mapstructure:"labels" json:"labels" yaml:"labels"` // comma-separated key-value pairs, i.e. "app=example_app,dc=sjc-1" EnabledDB bool `mapstructure:"log-db" json:"log-db" yaml:"log-db"` // log输出到数据库 }
type NSQOptions ¶
type NSQOptions struct { DialTimeout time.Duration `opt:"dial_timeout" default:"1s"` // Deadlines for network reads and writes ReadTimeout time.Duration `opt:"read_timeout" min:"100ms" max:"5m" default:"60s"` WriteTimeout time.Duration `opt:"write_timeout" min:"100ms" max:"5m" default:"1s"` // Addresses is the local address to use when dialing an nsqd. Addresses []string `opt:"addresses"` // Duration between polling lookupd for new producers, and fractional jitter to add to // the lookupd pool loop. this helps evenly distribute requests even if multiple consumers // restart at the same time // // NOTE: when not using nsqlookupd, LookupdPollInterval represents the duration of time between // reconnection attempts LookupdPollInterval time.Duration `opt:"lookupd_poll_interval" min:"10ms" max:"5m" default:"60s"` LookupdPollJitter float64 `opt:"lookupd_poll_jitter" min:"0" max:"1" default:"0.3"` // Maximum duration when REQueueing (for doubling of deferred requeue) MaxRequeueDelay time.Duration `opt:"max_requeue_delay" min:"0" max:"60m" default:"15m"` DefaultRequeueDelay time.Duration `opt:"default_requeue_delay" min:"0" max:"60m" default:"90s"` // Maximum amount of time to backoff when processing fails 0 == no backoff MaxBackoffDuration time.Duration `opt:"max_backoff_duration" min:"0" max:"60m" default:"2m"` // Unit of time for calculating consumer backoff BackoffMultiplier time.Duration `opt:"backoff_multiplier" min:"0" max:"60m" default:"1s"` // Maximum number of times this consumer will attempt to process a message before giving up MaxAttempts uint16 `opt:"max_attempts" min:"0" max:"65535" default:"5"` // Duration to wait for a message from an nsqd when in a state where RDY // counts are re-distributed (e.g. max_in_flight < num_producers) LowRdyIdleTimeout time.Duration `opt:"low_rdy_idle_timeout" min:"1s" max:"5m" default:"10s"` // Duration to wait until redistributing RDY for an nsqd regardless of LowRdyIdleTimeout LowRdyTimeout time.Duration `opt:"low_rdy_timeout" min:"1s" max:"5m" default:"30s"` // Duration between redistributing max-in-flight to connections RDYRedistributeInterval time.Duration `opt:"rdy_redistribute_interval" min:"1ms" max:"5s" default:"5s"` // Identifiers sent to nsqd representing this client // UserAgent is in the spirit of HTTP (default: "<client_library_name>/<version>") ClientID string `opt:"client_id"` // (defaults: short hostname) Hostname string `opt:"hostname"` UserAgent string `opt:"user_agent"` // Duration of time between heartbeats. This must be less than ReadTimeout HeartbeatInterval time.Duration `opt:"heartbeat_interval" default:"30s"` // Integer percentage to sample the channel (requires nsqd 0.2.25+) SampleRate int32 `opt:"sample_rate" min:"0" max:"99"` Tls *Tls `yaml:"tls" json:"tls"` // Compression Settings Deflate bool `opt:"deflate"` DeflateLevel int `opt:"deflate_level" min:"1" max:"9" default:"6"` Snappy bool `opt:"snappy"` // Size of the buffer (in bytes) used by nsqd for buffering writes to this connection OutputBufferSize int64 `opt:"output_buffer_size" default:"16384"` // Timeout used by nsqd before flushing buffered writes (set to 0 to disable). // // WARNING: configuring clients with an extremely low // (< 25ms) output_buffer_timeout has a significant effect // on nsqd CPU usage (particularly with > 50 clients connected). OutputBufferTimeout time.Duration `opt:"output_buffer_timeout" default:"250ms"` // Maximum number of messages to allow in flight (concurrency knob) MaxInFlight int `opt:"max_in_flight" min:"0" default:"1"` // The server-side message timeout for messages delivered to this client MsgTimeout time.Duration `opt:"msg_timeout" min:"0"` // secret for nsqd authentication (requires nsqd 0.2.29+) AuthSecret string `opt:"auth_secret"` }
func (NSQOptions) GetNSQOptions ¶
func (e NSQOptions) GetNSQOptions() (*nsq.Config, error)
type Oss ¶ added in v1.0.20
type Qiniu ¶ added in v1.0.20
type Qiniu struct { Zone string `mapstructure:"zone" json:"zone" yaml:"zone"` // 存储区域 Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` // 空间名称 ImgPath string `mapstructure:"img-path" json:"imgPath" yaml:"img-path"` // CDN加速域名 UseHTTPS bool `mapstructure:"use-https" json:"useHttps" yaml:"use-https"` // 是否使用https AccessKey string `mapstructure:"access-key" json:"accessKey" yaml:"access-key"` // 秘钥AK SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` // 秘钥SK UseCdnDomains bool `mapstructure:"use-cdn-domains" json:"useCdnDomains" yaml:"use-cdn-domains"` // 上传是否使用CDN上传加速 }
type Queue ¶
type Queue struct { Redis *QueueRedis Memory *QueueMemory NSQ *QueueNSQ `json:"nsq" yaml:"nsq"` }
type QueueMemory ¶
type QueueMemory struct {
PoolSize uint
}
type QueueNSQ ¶
type QueueNSQ struct { NSQOptions ChannelPrefix string }
type QueueRedis ¶
type QueueRedis struct { RedisConnectOptions Producer *redisqueue.ProducerOptions Consumer *redisqueue.ConsumerOptions }
type RedisConnectOptions ¶
type RedisConnectOptions struct { Network string `yaml:"network" json:"network"` Addr string `yaml:"addr" json:"addr"` Username string `yaml:"username" json:"username"` Password string `yaml:"password" json:"password"` DB int `yaml:"db" json:"db"` PoolSize int `yaml:"pool_size" json:"pool_size"` Tls *Tls `yaml:"tls" json:"tls"` MaxRetries int `yaml:"max_retries" json:"max_retries"` }
func (RedisConnectOptions) GetRedisOptions ¶
func (e RedisConnectOptions) GetRedisOptions() (*redis.Options, error)
type Settings ¶
type Settings struct { Settings Config `yaml:"settings"` Extend interface{} `yaml:"extend"` // contains filtered or unexported fields }
Settings 兼容原先的配置结构
type Sms ¶ added in v1.0.20
type Smtp ¶ added in v1.31.0
type Smtp struct { Address string `mapstructure:"address" json:"address" yaml:"address"` Identity string `mapstructure:"identity" json:"identity" yaml:"identity"` Username string `mapstructure:"username" json:"username" yaml:"username"` Password string `mapstructure:"password" json:"password" yaml:"password"` Host string `mapstructure:"host" json:"host" yaml:"host"` }
type TencentCOS ¶ added in v1.0.20
type TencentCOS struct { Bucket string `mapstructure:"bucket" json:"bucket" yaml:"bucket"` Region string `mapstructure:"region" json:"region" yaml:"region"` SecretID string `mapstructure:"secret-id" json:"secretID" yaml:"secret-id"` SecretKey string `mapstructure:"secret-key" json:"secretKey" yaml:"secret-key"` BaseURL string `mapstructure:"base-url" json:"baseURL" yaml:"base-url"` PathPrefix string `mapstructure:"path-prefix" json:"pathPrefix" yaml:"path-prefix"` }
Click to show internal directories.
Click to hide internal directories.