config

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cfg = &Config{}
View Source
var SslConfig = new(Ssl)

Functions

func GetRedisClient added in v0.3.0

func GetRedisClient() *redis.Client

GetRedisClient 获取redis客户端

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"`
	UI         UIServer          `yaml:"ui" json:"ui"`
}

func (*Application) Init

func (e *Application) Init(r gin.IRouter)

type Auth

type Auth struct {
	Realm       string        `yaml:"realm" json:"realm"`
	Key         string        `yaml:"key" json:"key"`
	IdentityKey string        `yaml:"identityKey" json:"identityKey"`
	Timeout     time.Duration `yaml:"timeout" json:"timeout"`
	MaxRefresh  time.Duration `yaml:"maxRefresh" json:"maxRefresh"`
}

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{}
}

func (Cache) Init added in v0.3.0

func (e Cache) Init()

Init 构造cache 顺序 redis > 其他 > memory

type Cluster added in v0.4.6

type Cluster struct {
	Name           string      `yaml:"name" json:"name"`
	KubeConfig     string      `yaml:"kubeConfig" json:"kubeConfig"`
	KubeConfigPath string      `yaml:"kubeConfigPath" json:"kubeConfigPath"`
	EKS            *EKSCluster `yaml:"eks" json:"eks"`
	// contains filtered or unexported fields
}

func (*Cluster) GetClientSet added in v0.4.6

func (e *Cluster) GetClientSet() *kubernetes.Clientset

func (*Cluster) GetConfig added in v0.4.6

func (e *Cluster) GetConfig() *rest.Config

func (*Cluster) GetDynamicClient added in v0.4.6

func (e *Cluster) GetDynamicClient() *dynamic.DynamicClient

func (*Cluster) Init added in v0.4.6

func (e *Cluster) Init()

type Clusters added in v0.4.6

type Clusters []*Cluster

func (Clusters) GetClientSet added in v0.4.6

func (e Clusters) GetClientSet(name string) *kubernetes.Clientset

func (Clusters) GetConfig added in v0.4.6

func (e Clusters) GetConfig(name string) *rest.Config

func (Clusters) GetDynamicClient added in v0.4.6

func (e Clusters) GetDynamicClient(name string) *dynamic.DynamicClient

func (Clusters) Init added in v0.4.6

func (e Clusters) Init()

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"`
	Storage   *config.Storage `yaml:"storage" json:"storage"`
	Clusters  Clusters        `yaml:"clusters" json:"clusters"`
}

func (*Config) Init

func (e *Config) Init(opts ...source.Option)

func (*Config) OnChange

func (e *Config) OnChange()

type EKSCluster added in v0.4.6

type EKSCluster struct {
	Name   string `yaml:"name" json:"name"`
	Region string `yaml:"region" json:"region"`
}

func (*EKSCluster) GetKubeconfig added in v0.4.6

func (e *EKSCluster) GetKubeconfig() (*clientcmdapi.Config, error)

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
}

func (*Locker) Empty added in v0.3.0

func (e *Locker) Empty() bool

Empty 空设置

func (*Locker) Init added in v0.3.0

func (e *Locker) Init()

Init 启用顺序 redis > 其他 > memory

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

type Mode

type Mode string
const (
	ModeDev  Mode = "dev"
	ModeTest Mode = "test"
	ModeProd Mode = "prod"
)

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"`
}

func (*Pyroscope) Init

func (e *Pyroscope) Init()

func (*Pyroscope) MergeTags added in v0.3.6

func (e *Pyroscope) MergeTags(labels map[string]string)

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"`
}

func (*Queue) Empty added in v0.3.0

func (e *Queue) Empty() bool

Empty 空设置

func (*Queue) Init added in v0.3.0

func (e *Queue) Init()

Init 启用顺序 Redis > NSQ > Memory

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"`
}

func (*Secret) Get added in v0.3.4

func (s *Secret) Get(key string) (any, error)

Get value by key

func (*Secret) Init added in v0.3.4

func (s *Secret) Init()

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()

type Ssl added in v0.3.0

type Ssl struct {
	KeyStr string
	Pem    string
	Enable bool
	Domain string
}

type TLS added in v0.3.0

type TLS struct {
	Cert string `yaml:"cert" json:"cert"`
	Key  string `yaml:"key" json:"key"`
	Ca   string `yaml:"ca" json:"ca"`
}

type Task

type Task struct {
	Spec   string `yaml:"spec" json:"spec"`
	Enable bool   `yaml:"enable" json:"enable"`
}

type UIServer added in v0.4.4

type UIServer struct {
	Enabled       bool   `yaml:"enabled" json:"enabled"`
	Path          string `yaml:"path" json:"path"`
	config.Listen `yaml:",inline" json:",inline"`
}

func (*UIServer) Init added in v0.4.4

func (u *UIServer) Init() server.Runnable

Jump to

Keyboard shortcuts

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