config

package
v0.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelDebug = "DEBUG"
	LogLevelInfo  = "INFO"
	LogLevelWarn  = "WARN"
	LogLevelError = "ERROR"
)
View Source
const (
	LogFormatText = "text"
	LogFormatJson = "json"
)

Variables

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

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"`
	DatabaseConfig DatabaseConfig `yaml:"database" envconfig:"DATABASE"`
	RedisConfig    RedisConfig    `yaml:"redis" envconfig:"REDIS"`
	AdminConfig    AdminConfig    `yaml:"admin" envconfig:"ADMIN"`
	ProxyConfig    ProxyConfig    `yaml:"proxy" envconfig:"PROXY"`
	WorkerConfig   WorkerConfig   `yaml:"worker" envconfig:"WORKER"`
}

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

func (DatabaseConfig) GetDB

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

func (DatabaseConfig) Validate

func (cfg DatabaseConfig) Validate() error

type LogConfig

type LogConfig struct {
	Level  LogLevel `yaml:"level" default:"INFO"`
	Format string   `yaml:"format" default:"text"`
}

func (LogConfig) Validate

func (cfg LogConfig) Validate() error

type LogFormat

type LogFormat = string

type LogLevel

type LogLevel = string

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 {
	Redis RedisConfig `yaml:"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 WorkerConfig

type WorkerConfig struct {
	Enabled bool `yaml:"enabled" default:"false"`
}

func (*WorkerConfig) Validate

func (cfg *WorkerConfig) Validate() error

Jump to

Keyboard shortcuts

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