Help us shape the future of Go! Take the 2026 Go Developer Survey

config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 10 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 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 {
	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 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"`
	Deliverer WorkerDeliverer `yaml:"deliverer"`
}

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