config

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VERSION = "dev"
	COMMIT  = "unknown"
)

Functions

This section is empty.

Types

type AccessLogConfig added in v0.7.0

type AccessLogConfig struct {
	File   string    `yaml:"file" json:"file" default:"/dev/stdout"`
	Format LogFormat `yaml:"format" json:"format" default:"text"`
}

func (AccessLogConfig) Enabled added in v0.7.0

func (cfg AccessLogConfig) Enabled() bool

func (AccessLogConfig) Validate added in v0.7.0

func (cfg AccessLogConfig) Validate() error

type AdminConfig

type AdminConfig struct {
	Listen         string `yaml:"listen" json:"listen"`
	DebugEndpoints bool   `yaml:"debug_endpoints" json:"debug_endpoints" envconfig:"DEBUG_ENDPOINTS"`
	TLS            TLS    `yaml:"tls" json:"tls"`
}

func (AdminConfig) IsEnabled

func (cfg AdminConfig) IsEnabled() bool

func (AdminConfig) Validate

func (cfg AdminConfig) Validate() error

type Config

type Config struct {
	Log       LogConfig       `yaml:"log" json:"log" envconfig:"LOG"`
	AccessLog AccessLogConfig `yaml:"access_log" json:"access_log" envconfig:"ACCESS_LOG"`
	Database  DatabaseConfig  `yaml:"database" json:"database" envconfig:"DATABASE"`
	Redis     RedisConfig     `yaml:"redis" json:"redis" envconfig:"REDIS"`
	Admin     AdminConfig     `yaml:"admin" json:"admin" envconfig:"ADMIN"`
	Status    StatusConfig    `yaml:"status" json:"status" envconfig:"STATUS"`
	Proxy     ProxyConfig     `yaml:"proxy" json:"proxy" envconfig:"PROXY"`
	Worker    WorkerConfig    `yaml:"worker" json:"worker" envconfig:"WORKER"`
	Metrics   MetricsConfig   `yaml:"metrics" json:"metrics" envconfig:"METRICS"`
	Tracing   TracingConfig   `yaml:"tracing" json:"tracing" envconfig:"TRACING"`
	Role      Role            `yaml:"role" json:"role" envconfig:"ROLE" default:"standalone"`
}

func Init

func Init() (*Config, error)

func InitWithFile

func InitWithFile(filename string) (*Config, error)

func (*Config) OverrideByRole added in v0.8.0

func (cfg *Config) OverrideByRole(role Role)

func (Config) String

func (cfg Config) String() string

func (Config) Validate

func (cfg Config) Validate() error

type DatabaseConfig

type DatabaseConfig struct {
	Host        string   `yaml:"host" json:"host" default:"localhost"`
	Port        uint32   `yaml:"port" json:"port" default:"5432"`
	Username    string   `yaml:"username" json:"username" default:"webhookx"`
	Password    Password `yaml:"password" json:"password" default:""`
	Database    string   `yaml:"database" json:"database" default:"webhookx"`
	Parameters  string   `yaml:"parameters" json:"parameters" default:"application_name=webhookx&sslmode=disable&connect_timeout=10"`
	MaxPoolSize uint32   `yaml:"max_pool_size" json:"max_pool_size" default:"40" envconfig:"MAX_POOL_SIZE"`
	MaxLifetime uint32   `yaml:"max_life_time" json:"max_life_time" default:"1800" envconfig:"MAX_LIFETIME"`
}

func (DatabaseConfig) GetDSN added in v0.3.0

func (cfg DatabaseConfig) GetDSN() string

func (DatabaseConfig) Validate

func (cfg DatabaseConfig) Validate() error

type Export added in v0.3.0

type Export string
const (
	ExportOpenTelemetry Export = "opentelemetry"
)

type LogConfig

type LogConfig struct {
	File   string    `yaml:"file" json:"file" default:"/dev/stdout"`
	Level  LogLevel  `yaml:"level" json:"level" default:"info"`
	Format LogFormat `yaml:"format" json:"format" default:"text"`
}

func (LogConfig) Validate

func (cfg LogConfig) Validate() error

type LogFormat

type LogFormat string
const (
	LogFormatText LogFormat = "text"
	LogFormatJson LogFormat = "json"
)

type LogLevel

type LogLevel string
const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
)

type Map added in v0.3.0

type Map map[string]string

func (*Map) Decode added in v0.3.0

func (m *Map) Decode(value string) error

type MetricsConfig added in v0.3.0

type MetricsConfig struct {
	Attributes    Map           `yaml:"attributes" json:"attributes"`
	Exports       []Export      `yaml:"exports" json:"exports"`
	PushInterval  uint32        `yaml:"push_interval" json:"push_interval" default:"10" envconfig:"PUSH_INTERVAL"`
	Opentelemetry Opentelemetry `yaml:"opentelemetry" json:"opentelemetry"`
}

func (*MetricsConfig) Validate added in v0.3.0

func (cfg *MetricsConfig) Validate() error

type Opentelemetry added in v0.3.0

type Opentelemetry struct {
	Protocol OtlpProtocol `yaml:"protocol" json:"protocol" envconfig:"PROTOCOL" default:"http/protobuf"`
	Endpoint string       `yaml:"endpoint" json:"endpoint" envconfig:"ENDPOINT" default:"http://localhost:4318/v1/metrics"`
}

func (Opentelemetry) Validate added in v0.3.0

func (cfg Opentelemetry) Validate() error

type OtlpProtocol added in v0.3.0

type OtlpProtocol string
const (
	OtlpProtocolGRPC OtlpProtocol = "grpc"
	OtlpProtocolHTTP OtlpProtocol = "http/protobuf"
)

type Password added in v0.8.0

type Password string

func (Password) MarshalJSON added in v0.8.0

func (p Password) MarshalJSON() ([]byte, error)

type Pool added in v0.3.0

type Pool struct {
	Size        uint32 `yaml:"size" json:"size" default:"10000"`
	Concurrency uint32 `yaml:"concurrency" json:"concurrency"`
}

type ProxyConfig

type ProxyConfig struct {
	Listen             string        `yaml:"listen" json:"listen"`
	TLS                TLS           `yaml:"tls" json:"tls"`
	TimeoutRead        int64         `yaml:"timeout_read" json:"timeout_read" default:"10" envconfig:"TIMEOUT_READ"`
	TimeoutWrite       int64         `yaml:"timeout_write" json:"timeout_write" default:"10" envconfig:"TIMEOUT_WRITE"`
	MaxRequestBodySize int64         `yaml:"max_request_body_size" json:"max_request_body_size" default:"1048576" envconfig:"MAX_REQUEST_BODY_SIZE"`
	Response           ProxyResponse `yaml:"response" json:"response"`
	Queue              Queue         `yaml:"queue" json:"queue"`
}

func (ProxyConfig) IsEnabled

func (cfg ProxyConfig) IsEnabled() bool

func (ProxyConfig) Validate

func (cfg ProxyConfig) Validate() error

type ProxyResponse

type ProxyResponse struct {
	Code        uint   `yaml:"code" json:"code" default:"200"`
	ContentType string `yaml:"content_type" json:"content_type" default:"application/json" envconfig:"CONTENT_TYPE"`
	Body        string `yaml:"body" json:"body" default:"{\"message\": \"OK\"}"`
}

type Queue

type Queue struct {
	Type  QueueType   `yaml:"type" json:"type" default:"redis"`
	Redis RedisConfig `yaml:"redis" json:"redis"`
}

func (Queue) Validate added in v0.3.0

func (cfg Queue) Validate() error

type QueueType added in v0.3.0

type QueueType string
const (
	QueueTypeOff   QueueType = "off"
	QueueTypeRedis QueueType = "redis"
)

type RedisConfig

type RedisConfig struct {
	Host     string   `yaml:"host" json:"host" default:"localhost"`
	Port     uint32   `yaml:"port" json:"port" default:"6379"`
	Password Password `yaml:"password" json:"password" default:""`
	Database uint32   `yaml:"database" json:"database" default:"0"`
}

func (RedisConfig) GetClient

func (cfg RedisConfig) GetClient() *redis.Client

func (RedisConfig) Validate

func (cfg RedisConfig) Validate() error

type Role added in v0.8.0

type Role string
const (
	RoleStandalone Role = "standalone"
	RoleCP         Role = "cp"
	RoleDPWorker   Role = "dp_worker"
	RoleDPProxy    Role = "dp_proxy"
)

type StatusConfig added in v0.8.0

type StatusConfig struct {
	Listen         string `yaml:"listen" json:"listen" default:"127.0.0.1:8082"`
	DebugEndpoints bool   `yaml:"debug_endpoints" json:"debug_endpoints" default:"true" envconfig:"DEBUG_ENDPOINTS"`
}

func (StatusConfig) IsEnabled added in v0.8.0

func (cfg StatusConfig) IsEnabled() bool

func (StatusConfig) Validate added in v0.8.0

func (cfg StatusConfig) Validate() error

type TLS added in v0.5.0

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

func (TLS) Enabled added in v0.5.0

func (cfg TLS) Enabled() bool

type TracingConfig added in v0.4.0

type TracingConfig struct {
	Enabled       bool          `yaml:"enabled" json:"enabled" default:"false"`
	Attributes    Map           `yaml:"attributes" json:"attributes"`
	Opentelemetry Opentelemetry `yaml:"opentelemetry" json:"opentelemetry"`
	SamplingRate  float64       `yaml:"sampling_rate" json:"sampling_rate" default:"1.0" envconfig:"SAMPLING_RATE"`
}

func (TracingConfig) Validate added in v0.4.0

func (cfg TracingConfig) Validate() error

type WorkerConfig

type WorkerConfig struct {
	Enabled   bool            `yaml:"enabled" json:"enabled" default:"false"`
	Deliverer WorkerDeliverer `yaml:"deliverer" json:"deliverer"`
	Pool      Pool            `yaml:"pool" json:"pool"`
}

func (*WorkerConfig) Validate

func (cfg *WorkerConfig) Validate() error

type WorkerDeliverer

type WorkerDeliverer struct {
	Timeout int64 `yaml:"timeout" json:"timeout" default:"60000"`
}

Jump to

Keyboard shortcuts

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