Documentation
¶
Index ¶
- Variables
- func GetRedisClient() *redis.Client
- func SetRedisClient(c *redis.Client)
- type AWSSecretManager
- type Application
- type Auth
- type Cache
- type Config
- type K8SSecretManager
- type Kafka
- type KafkaParams
- type Locker
- type MSKAccessTokenProvider
- type Mode
- type NSQOptions
- type Pyroscope
- type Queue
- type QueueMemory
- type QueueNSQ
- type QueueRedis
- type RedisConnectOptions
- type SASL
- type Secret
- type SecretConfig
- type Ssl
- type TLS
- type Task
Constants ¶
This section is empty.
Variables ¶
View Source
var Cfg = &Config{}
View Source
var FS embed.FS
View Source
var SslConfig = new(Ssl)
Functions ¶
func SetRedisClient ¶ added in v0.3.0
func SetRedisClient(c *redis.Client)
SetRedisClient 设置redis客户端
Types ¶
type AWSSecretManager ¶ added in v0.3.4
type AWSSecretManager struct {
SecretName string `yaml:"secretName" json:"secretName"`
Region string `yaml:"region" json:"region"`
AccessKeyID string `yaml:"accessKeyID" json:"accessKeyID"`
SecretAccessKey string `yaml:"secretAccessKey" json:"secretAccessKey"`
VersionStage string `yaml:"versionStage" json:"versionStage"`
// contains filtered or unexported fields
}
type Application ¶
type Application struct {
Name string `yaml:"name" json:"name"`
Mode Mode `yaml:"mode" json:"mode"`
Origin string `yaml:"origin" json:"origin"`
StaticPath map[string]string `yaml:"staticPath" json:"staticPath"`
Labels map[string]string `yaml:"labels" json:"labels"`
}
func (*Application) Init ¶
func (e *Application) Init(r gin.IRouter)
type Cache ¶ added in v0.3.0
type Cache struct {
QueryCache bool `yaml:"queryCache" json:"queryCache"`
QueryCacheDuration time.Duration `yaml:"queryCacheDuration" json:"queryCacheDuration"`
QueryCacheKeys []string `yaml:"queryCacheKeys" json:"queryCacheKeys"`
Redis *RedisConnectOptions
Memory interface{}
}
type Config ¶
type Config struct {
Auth Auth `yaml:"auth" json:"auth"`
GRPC config.GRPC `yaml:"grpc" json:"grpc"`
Logger config.Logger `yaml:"logger" json:"logger"`
Server config.Listen `yaml:"server" json:"server"`
Listen *config.Listen `yaml:"listen" json:"listen"`
Database gormdb.Database `yaml:"database" json:"database"`
Application Application `yaml:"application" json:"application"`
//OAuth2 *config.OAuth2 `yaml:"oauth2" json:"oauth2"`
Task Task `yaml:"task" json:"task"`
Pyroscope Pyroscope `yaml:"pyroscope" json:"pyroscope"`
Cache *Cache `yaml:"cache" json:"cache"`
Queue *Queue `yaml:"queue" json:"queue"`
Locker *Locker `yaml:"locker" json:"locker"`
Secret *Secret `yaml:"secret" json:"secret"`
}
type K8SSecretManager ¶ added in v0.3.4
type K8SSecretManager struct {
Namespace string `yaml:"namespace" json:"namespace"`
SecretName string `yaml:"secretName" json:"secretName"`
KubeConfig string `yaml:"kubeConfig" json:"kubeConfig"`
KubeConfigPath string `yaml:"kubeConfigPath" json:"kubeConfigPath"`
// contains filtered or unexported fields
}
type Kafka ¶ added in v0.3.0
type Kafka struct {
KafkaParams `yaml:",inline" json:",inline"`
SASL *SASL `yaml:"sasl" json:"sasl"`
}
type KafkaParams ¶ added in v0.3.0
type KafkaParams struct {
Brokers []string `yaml:"brokers" json:"brokers"`
CaFile string `yaml:"caFile" json:"caFile"`
CertFile string `yaml:"certFile" json:"certFile"`
KeyFile string `yaml:"keyFile" json:"keyFile"`
Timeout time.Duration `yaml:"timeout" json:"timeout"` // default: 30
KeepAlive time.Duration `yaml:"keepAlive" json:"keepAlive"`
Version string `yaml:"version" json:"version"`
Provider string `yaml:"provider" json:"provider"`
}
type Locker ¶ added in v0.3.0
type Locker struct {
Redis *RedisConnectOptions
}
type MSKAccessTokenProvider ¶ added in v0.3.3
type MSKAccessTokenProvider struct {
Region string
Ctx context.Context
// contains filtered or unexported fields
}
func (*MSKAccessTokenProvider) Token ¶ added in v0.3.3
func (m *MSKAccessTokenProvider) Token() (*sarama.AccessToken, error)
type NSQOptions ¶ added in v0.3.0
type NSQOptions struct {
DialTimeout time.Duration `opt:"dial_timeout" default:"1s"`
LookupdAddr string `opt:"-" json:"lookupdAddr" yaml:"lookupdAddr"`
AdminAddr string `opt:"-" json:"adminAddr" yaml:"adminAddr"`
// 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" yaml:"addresses" json:"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 ¶ added in v0.3.0
func (e NSQOptions) GetNSQOptions() (*nsq.Config, error)
type Pyroscope ¶
type Pyroscope struct {
Enabled bool `yaml:"enabled" json:"enabled"`
ApplicationName string `yaml:"applicationName" json:"applicationName"` // e.g backend.purchases
Tags map[string]string `yaml:"tags" json:"tags"`
ServerAddress string `yaml:"serverAddress" json:"serverAddress"` // e.g http://pyroscope.services.internal:4040
AuthToken string `yaml:"authToken" json:"authToken"` // specify this token when using pyroscope cloud
BasicAuthUser string `yaml:"basicAuthUser" json:"basicAuthUser"` // http basic auth user
BasicAuthPassword string `yaml:"basicAuthPassword" json:"basicAuthPassword"` // http basic auth password
TenantID string `yaml:"tenantID" json:"tenantID"`
UploadRate time.Duration `yaml:"uploadRate" json:"uploadRate"`
Logger bool `yaml:"logger" json:"logger"`
ProfileTypes []pyroscope.ProfileType `yaml:"profileTypes" json:"profileTypes"`
DisableGCRuns bool `yaml:"disableGCRuns" json:"disableGCRuns"` // this will disable automatic runtime.GC runs between getting the heap profiles
DisableAutomaticResets bool `yaml:"disableAutomaticResets" json:"disableAutomaticResets"` // disable automatic profiler reset every 10 seconds. Reset manually by calling Flush method
HTTPHeaders map[string]string `yaml:"httpHeaders" json:"httpHeaders"`
}
type Queue ¶ added in v0.3.0
type Queue struct {
Redis *QueueRedis
Memory *QueueMemory
NSQ *QueueNSQ `json:"nsq" yaml:"nsq"`
Kafka *Kafka `json:"kafka" yaml:"kafka"`
}
type QueueMemory ¶ added in v0.3.0
type QueueMemory struct {
PoolSize uint `yaml:"poolSize" json:"poolSize"`
}
type QueueNSQ ¶ added in v0.3.0
type QueueNSQ struct {
NSQOptions `yaml:",inline" json:",inline"`
}
type QueueRedis ¶ added in v0.3.0
type QueueRedis struct {
RedisConnectOptions `y`
Producer *redisqueue.ProducerOptions
Consumer *redisqueue.ConsumerOptions
}
type RedisConnectOptions ¶ added in v0.3.0
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 ¶ added in v0.3.0
func (e RedisConnectOptions) GetRedisOptions() (*redis.Options, error)
type SASL ¶ added in v0.3.0
type SASL struct {
Region string `yaml:"region" json:"region"`
// Whether or not to use SASL authentication when connecting to the broker
// (defaults to false).
Enable bool `yaml:"enable" json:"enable"`
// SASLMechanism is the name of the enabled SASL mechanism.
// Possible values: OAUTHBEARER, PLAIN (defaults to PLAIN).
Mechanism sarama.SASLMechanism `yaml:"mechanism" json:"mechanism"`
// Version is the SASL Protocol Version to use
// Kafka > 1.x should use V1, except on Azure EventHub which use V0
Version int16 `yaml:"version" json:"version"`
// Whether or not to send the Kafka SASL handshake first if enabled
// (defaults to true). You should only set this to false if you're using
// a non-Kafka SASL proxy.
Handshake bool `yaml:"handshake" json:"handshake"`
// AuthIdentity is an (optional) authorization identity (authzid) to
// use for SASL/PLAIN authentication (if different from User) when
// an authenticated user is permitted to act as the presented
// alternative user. See RFC4616 for details.
AuthIdentity string `yaml:"authIdentity" json:"authIdentity"`
// User is the authentication identity (authcid) to present for
// SASL/PLAIN or SASL/SCRAM authentication
User string `yaml:"user" json:"user"`
// Password for SASL/PLAIN authentication
Password string `yaml:"password" json:"password"`
// authz id used for SASL/SCRAM authentication
SCRAMAuthzID string `yaml:"scramAuthzID" json:"scramAuthzID"`
GSSAPI sarama.GSSAPIConfig `yaml:"gssapi" json:"gssapi"`
}
type Secret ¶ added in v0.3.4
type Secret struct {
EnvPrefix string `yaml:"envPrefix" json:"envPrefix"`
Keys []string `yaml:"keys" json:"keys"`
AWS *AWSSecretManager `yaml:"aws" json:"aws"`
K8S *K8SSecretManager `yaml:"k8s" json:"k8s"`
}
type SecretConfig ¶ added in v0.3.4
type SecretConfig struct {
Secret *Secret `yaml:"secret" json:"secret"`
}
func (*SecretConfig) Init ¶ added in v0.3.4
func (s *SecretConfig) Init()
Click to show internal directories.
Click to hide internal directories.