config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 54 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var URLTemplate = map[ProviderType]string{
	OSS:  "https://%s.aliyuncs.com",
	OOS:  "https://oos-%s.ctyunapi.cn",
	KODO: "https://s3-%s.qiniucs.com",
	COS:  "https://cos.%s.myqcloud.com",
	OBS:  "https://obs.%s.myhuaweicloud.com",
	BOS:  "https://s3.%s.bcebos.com",
	GCS:  "https://storage.googleapis.com",
	KS3:  "https://ks3-%s.ksyuncs.com",
}

URLTemplate storage provider url template

Functions

func GetAcceptEncodingKey added in v0.0.5

func GetAcceptEncodingKey(ctx context.Context) (v string)

func Init

func Init(cfg source.Entity, options ...source.Option) (err error)

Init 初始化配置

func SetAcceptEncodingKey added in v0.0.5

func SetAcceptEncodingKey(ctx context.Context, value string) context.Context

Types

type Cache added in v0.2.9

type Cache struct {
	QueryCache         bool          `yaml:"queryCache" json:"queryCache"`
	QueryCacheDuration time.Duration `yaml:"queryCacheDuration" json:"queryCacheDuration"`
	QueryCacheKeys     []string      `yaml:"queryCacheKeys" json:"queryCacheKeys"`
	Redis              *storage.RedisConnectOptions
	Memory             interface{}
}

func (Cache) Init added in v0.2.9

func (e Cache) Init(set func(storage.AdapterCache), queryCache func(tx *gorm.DB, duration time.Duration))

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

type Clients added in v0.1.5

type Clients map[string]ServerParams

type Endpoint added in v0.1.1

type Endpoint struct {
	AuthURL       string `yaml:"authURL" json:"authURL"`
	DeviceAuthURL string `yaml:"deviceAuthURL" json:"deviceAuthURL"`
	TokenURL      string `yaml:"tokenURL" json:"tokenURL"`

	// AuthStyle optionally specifies how the endpoint wants the
	// client ID & client secret sent. The zero value means to
	// auto-detect.
	AuthStyle int `yaml:"authStyle" json:"authStyle"`
}

type GRPC

type GRPC struct {
	ServerParams `yaml:",inline" json:",inline"`
	Clients      Clients `yaml:"client" json:"client"`
}

GRPC grpc服务公共配置(选用)

func (*GRPC) GetGRPCClient added in v0.1.5

func (e *GRPC) GetGRPCClient(key string, opts ...grpc.DialOption) *grpc.ClientConn

func (*GRPC) Init

func (e *GRPC) Init(
	register func(srv *serverGRPC.Server),
	opts ...serverGRPC.Option) server.Runnable

Init grpc server

type Kafka added in v0.2.9

type Kafka struct {
	KafkaParams `yaml:",inline" json:",inline"`
	SASL        *SASL `yaml:"sasl" json:"sasl"`
}

type KafkaParams added in v0.2.9

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 Limiter added in v0.1.0

type Limiter interface {
	Allow() bool
	Wait(context.Context) error
}

type LimiterName added in v0.1.0

type LimiterName string
const (
	SingleLimiter LimiterName = "single"
)

type Listen

type Listen struct {
	Name     string `yaml:"name" json:"name"`
	Addr     string `yaml:"addr" json:"addr"`
	CertFile string `yaml:"certFile" json:"certFile"`
	KeyFile  string `yaml:"keyFile" json:"keyFile"`
	Timeout  int    `yaml:"timeout" json:"timeout"` // default: 10s
	Metrics  bool   `yaml:"metrics" json:"metrics"`
	Healthz  bool   `yaml:"healthz" json:"healthz"`
	Readyz   bool   `yaml:"readyz" json:"readyz"`
	Pprof    bool   `yaml:"pprof" json:"pprof"`
}

Listen tcp listener config

func (*Listen) Init

func (e *Listen) Init(opts ...listener.Option) server.Runnable

Init tcp listener

type Locker added in v0.2.9

type Locker struct {
	Redis *storage.RedisConnectOptions
}

func (*Locker) Empty added in v0.2.9

func (e *Locker) Empty() bool

Empty 空设置

func (*Locker) Init added in v0.2.9

func (e *Locker) Init(set func(storage.AdapterLocker))

Init 启用顺序 redis > 其他 > memory

type Logger

type Logger struct {
	Path       string     `yaml:"path" json:"path"`
	Level      slog.Level `yaml:"level" json:"level"`
	Stdout     string     `yaml:"stdout" json:"stdout"`
	AddSource  bool       `yaml:"addSource" json:"addSource"`
	Cap        uint       `yaml:"cap" json:"cap"`
	Json       bool       `yaml:"json" json:"json"`
	BufferSize uint       `yaml:"bufferSize" json:"bufferSize"`
}

Logger logger配置

func (*Logger) GormLevel added in v0.0.5

func (e *Logger) GormLevel() logger.LogLevel

func (*Logger) Init

func (e *Logger) Init()

Init 初始化日志

type Loki added in v0.1.9

type Loki struct {
	URL      string            `yaml:"url" json:"url"`
	Labels   map[string]string `yaml:"labels" json:"labels"`
	Interval time.Duration     `yaml:"interval" json:"interval"`
}

func (*Loki) MergeLabels added in v0.1.9

func (l *Loki) MergeLabels(labels map[string]string)

type MSKAccessTokenProvider added in v0.2.9

type MSKAccessTokenProvider struct {
	Region string
	Ctx    context.Context
	// contains filtered or unexported fields
}

func (*MSKAccessTokenProvider) Token added in v0.2.9

type OAuth2

type OAuth2 struct {
	Issuer       string   `yaml:"issuer" json:"issuer"`
	Endpoint     Endpoint `yaml:"endpoint" json:"endpoint"`
	ClientID     string   `yaml:"clientID" json:"clientID"`
	ClientSecret string   `yaml:"clientSecret" json:"clientSecret"`
	Scopes       []string `yaml:"scopes" json:"scopes"`
	RedirectURL  string   `yaml:"redirectURL" json:"redirectURL"`
	AllowGroup   []string `yaml:"allowGroup" json:"allowGroup"`
}

OAuth2 holds the configuration for the OAuth2 provider.

func (*OAuth2) GetClientID

func (e *OAuth2) GetClientID() string

GetClientID returns the OAuth2 client ID.

func (*OAuth2) GetClientSecret

func (e *OAuth2) GetClientSecret() string

GetClientSecret returns the OAuth2 client secret.

func (*OAuth2) GetIssuer

func (e *OAuth2) GetIssuer() string

GetIssuer returns the OAuth2 issuer.

func (*OAuth2) GetOAuth2Config

func (e *OAuth2) GetOAuth2Config(c context.Context) (*oauth2.Config, error)

GetOAuth2Config returns an oauth2.Config.

func (*OAuth2) GetRedirectURL

func (e *OAuth2) GetRedirectURL() string

GetRedirectURL returns the OAuth2 redirect URL.

func (*OAuth2) GetScopes

func (e *OAuth2) GetScopes() []string

GetScopes returns the OAuth2 scopes.

type ProviderType

type ProviderType string

ProviderType storage provider type

const (
	// S3 aws s3
	S3 ProviderType = "s3"
	// OSS aliyun oss
	OSS ProviderType = "oss"
	// OOS ctyun oos
	OOS ProviderType = "oos"
	// KODO qiniu kodo
	KODO ProviderType = "kodo"
	// COS tencent cos
	COS ProviderType = "cos"
	// OBS huawei obs
	OBS ProviderType = "obs"
	// BOS baidu bos
	BOS ProviderType = "bos"
	// GCS google gcs
	GCS ProviderType = "gcs"
	// KS3 kingsoft ks3
	KS3 ProviderType = "ks3"
	// MINIO minio storage
	MINIO ProviderType = "minio"
)

type Queue added in v0.2.9

type Queue struct {
	Redis  *QueueRedis  `json:"redis" yaml:"redis"`
	Memory *QueueMemory `json:"memory" yaml:"memory"`
	NSQ    *QueueNSQ    `json:"nsq" yaml:"nsq"`
	Kafka  *Kafka       `json:"kafka" yaml:"kafka"`
}

func (*Queue) Empty added in v0.2.9

func (e *Queue) Empty() bool

Empty 空设置

func (*Queue) Init added in v0.2.9

func (e *Queue) Init(set func(storage.AdapterQueue))

Init 启用顺序 Redis > NSQ > Memory

type QueueMemory added in v0.2.9

type QueueMemory struct {
	PoolSize uint `yaml:"poolSize" json:"poolSize"`
}

type QueueNSQ added in v0.2.9

type QueueNSQ struct {
	storage.NSQOptions `yaml:",inline" json:",inline"`
}

type QueueRedis added in v0.2.9

type QueueRedis struct {
	storage.RedisConnectOptions
	Producer *redisqueue.ProducerOptions
	Consumer *redisqueue.ConsumerOptions
}

type RateLimit added in v0.1.0

type RateLimit struct {
	// 限流器类型
	Name LimiterName `json:"name" yaml:"name"`
	// 限流器配置
	Rate float64 `json:"rate" yaml:"rate"`
	// 限流器最大存储令牌数
	Bursts int `json:"bursts" yaml:"bursts"`
}

func (*RateLimit) Init added in v0.1.0

func (e *RateLimit) Init() Limiter

func (*RateLimit) String added in v0.1.0

func (e *RateLimit) String() string

type SASL added in v0.2.9

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 ServerParams added in v0.1.5

type ServerParams struct {
	Addr     string        `yaml:"addr" json:"addr"` // default:  :9090
	CertFile string        `yaml:"certFile" json:"certFile"`
	KeyFile  string        `yaml:"keyFile" json:"keyFile"`
	Timeout  time.Duration `yaml:"timeout" json:"timeout"` // default: 10
}

type Storage

type Storage struct {
	Type            ProviderType `yaml:"type"`
	SigningMethod   string       `yaml:"signingMethod"`
	Region          string       `yaml:"region"`
	Bucket          string       `yaml:"bucket"`
	Endpoint        string       `yaml:"endpoint"`
	AccessKeyID     string       `yaml:"accessKeyID"`
	SecretAccessKey string       `yaml:"secretAccessKey"`
	// contains filtered or unexported fields
}

Storage storage

func (*Storage) GetClient

func (o *Storage) GetClient() *s3.Client

GetClient get client

func (*Storage) Init

func (o *Storage) Init()

Init init

type TLS

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

TLS config

func (*TLS) GetTLS

func (c *TLS) GetTLS() (*tls.Config, error)

GetTLS get tls config

Directories

Path Synopsis
fs
s3

Jump to

Keyboard shortcuts

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