config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VERSION = "dev"
	COMMIT  = "unknown"
	NODE    = uuid.NewV4().String()
)

Functions

This section is empty.

Types

type AdminConfig

type AdminConfig struct {
	Listen string `yaml:"listen"`
}

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" envconfig:"LOG"`
	Database DatabaseConfig `yaml:"database" envconfig:"DATABASE"`
	Redis    RedisConfig    `yaml:"redis" envconfig:"REDIS"`
	Admin    AdminConfig    `yaml:"admin" envconfig:"ADMIN"`
	Proxy    ProxyConfig    `yaml:"proxy" envconfig:"PROXY"`
	Worker   WorkerConfig   `yaml:"worker" envconfig:"WORKER"`
	Metrics  MetricsConfig  `yaml:"metrics" envconfig:"METRICS"`
	Tracing  TracingConfig  `yaml:"tracing" envconfig:"TRACING"`
}

func Init

func Init() (*Config, error)

func InitWithFile

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

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" default:"localhost"`
	Port        uint32 `yaml:"port" default:"5432"`
	Username    string `yaml:"username" default:"webhookx"`
	Password    string `yaml:"password" default:""`
	Database    string `yaml:"database" default:"webhookx"`
	Parameters  string `yaml:"parameters" default:"application_name=webhookx&sslmode=disable&connect_timeout=10"`
	MaxPoolSize uint32 `yaml:"max_pool_size" default:"40" envconfig:"MAX_POOL_SIZE"`
	MaxLifetime uint32 `yaml:"max_life_time" default:"1800" envconfig:"MAX_LIFETIME"`
}

func (DatabaseConfig) GetDSN added in v0.3.0

func (cfg DatabaseConfig) GetDSN() string

func (*DatabaseConfig) InitSqlDB added in v0.4.0

func (cfg *DatabaseConfig) InitSqlDB() (*sql.DB, error)

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" default:"/dev/stdout"`
	Level  LogLevel  `yaml:"level" default:"info"`
	Format LogFormat `yaml:"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" envconfig:"ATTRIBUTES"`
	Exports       []Export      `yaml:"exports" envconfig:"EXPORTS"`
	PushInterval  uint32        `yaml:"push_interval" default:"10"`
	Opentelemetry Opentelemetry `yaml:"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" envconfig:"PROTOCOL" default:"http/protobuf"`
	Endpoint string       `yaml:"endpoint" envconfig:"ENDPOINT" default:"http://localhost:4318/v1/metrics"`
	// Deprecated: used by MetricsConfig
	PushInterval uint32 `yaml:"push_interval" default:"10"`
}

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 Pool added in v0.3.0

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

type ProxyConfig

type ProxyConfig struct {
	Listen             string        `yaml:"listen"`
	TimeoutRead        int64         `yaml:"timeout_read" default:"10"`
	TimeoutWrite       int64         `yaml:"timeout_write" default:"10"`
	MaxRequestBodySize int64         `yaml:"max_request_body_size" default:"1048576"`
	Response           ProxyResponse `yaml:"response"`
	Queue              Queue         `yaml:"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" default:"200"`
	ContentType string `yaml:"contentType" default:"application/json"`
	Body        string `yaml:"body" default:"{\"message\": \"OK\"}"`
}

type Queue

type Queue struct {
	Type  QueueType   `yaml:"type" default:"redis"`
	Redis RedisConfig `yaml:"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" default:"localhost"`
	Port     uint32 `yaml:"port" default:"6379"`
	Password string `yaml:"password" default:""`
	Database uint32 `yaml:"database" default:"0"`
}

func (RedisConfig) GetClient

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

func (RedisConfig) Validate

func (cfg RedisConfig) Validate() error

type TracingConfig added in v0.4.0

type TracingConfig struct {
	Enabled       bool          `yaml:"enabled" default:"false"`
	Attributes    Map           `yaml:"attributes"`
	Opentelemetry Opentelemetry `yaml:"opentelemetry"`
	SamplingRate  float64       `yaml:"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" default:"false"`
	Deliverer WorkerDeliverer `yaml:"deliverer"`
	Pool      Pool            `yaml:"pool"`
}

func (*WorkerConfig) Validate

func (cfg *WorkerConfig) Validate() error

type WorkerDeliverer

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

Jump to

Keyboard shortcuts

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