app

package module
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2025 License: MIT Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RabbitBackoffPolicy = []time.Duration{
	100 * time.Millisecond,
	200 * time.Millisecond,
	500 * time.Millisecond,
	time.Second,
}

Functions

func Migrate

func Migrate(ctx context.Context, cnf DatabaseConfig, migrations embed.FS, dir string) error

func MustLoadConfig

func MustLoadConfig[T any]() *T

func MustRun

func MustRun(
	ctx context.Context,
	cnf Config,
	logOutput io.Writer,
	processor Processor,
	modificators ...Option,
)

func MustRunOnce added in v1.11.5

func MustRunOnce(
	ctx context.Context,
	cnf Config,
	logOutput io.Writer,
	processor Processor,
	modificators ...Option,
)

func MustSetupLogger

func MustSetupLogger(stage, level string, debug, local bool, writer io.Writer) zerolog.Logger

Types

type Closable added in v1.11.5

type Closable func(ctx context.Context) error

func (Closable) Close added in v1.11.5

func (c Closable) Close(ctx context.Context) error

type Config

type Config struct {
	Env               string  `env:"APP_ENV" env-default:"local"`
	Stage             string  `env:"APP_STAGE"`
	Debug             bool    `env:"APP_DEBUG" env-default:"true"`
	Local             bool    `env:"LOCAL"`
	LogLevel          string  `env:"LOG_LEVEL" env-default:"info"`
	TraceSample       float64 `env:"TRACE_SAMPLE" env-default:"0.8"`
	HealthCheckPeriod string  `env:"HEALTH_CHECK_PERIOD" env-default:"15s"`
}

type DatabaseConfig

type DatabaseConfig struct {
	Port           uint32 `env:"DB_PORT" env-default:"5432"`
	Host           string `env:"DB_HOST" env-default:"localhost"`
	Name           string `env:"DB_NAME" env-default:"app"`
	User           string `env:"DB_USER" env-default:"user" vault:"POSTGRESQL_USERNAME"`
	Password       string `env:"DB_PWD" vault:"POSTGRESQL_PASSWORD"`
	MaxConnections byte   `env:"DB_MAX_CONN" env-default:"5"`
	MinConnections byte   `env:"DB_MIN_CONN" env-default:"1"`
	Debug          bool   `env:"DB_DEBUG" env-default:"false"`
}

type FiberRouterSetup added in v1.3.0

type FiberRouterSetup = func(*fiber.App)

type GRPCConfig added in v1.3.0

type GRPCConfig struct {
	MaxConnectionLifetime time.Duration
	Port                  int
	DisableHealthEndpoint bool
}

type GRPCRouterSetup added in v1.3.0

type GRPCRouterSetup = func(*gRPC.Server)

type HTTPConfig added in v1.3.0

type HTTPConfig struct {
	Timeouts struct {
		Read     string `env:"TIMEOUT_READ" env-default:"5s"`
		Write    string `env:"TIMEOUT_WRITE" env-default:"5s"`
		Shutdown string `env:"TIMEOUT_SHUTDOWN" env-default:"3s"`
	}
	ReadBufferSize         int
	WriteBufferSize        int
	Port                   int
	DisableDefaultHandlers bool
	DisableActuator        bool
}

type Once added in v1.11.5

type Once func(ctx context.Context)

func (Once) Run added in v1.11.5

func (r Once) Run(ctx context.Context)

type Option

type Option struct {
	// contains filtered or unexported fields
}

func WithDatabase

func WithDatabase(cnf DatabaseConfig) Option

func WithFiberServer added in v1.3.0

func WithFiberServer(
	cnf HTTPConfig,
	appConfig any,
	setup FiberRouterSetup,
) Option

func WithFinalizer

func WithFinalizer(name string, finalizer Closable) Option

func WithGRPCServer added in v1.3.0

func WithGRPCServer(cnf GRPCConfig, setup GRPCRouterSetup) Option

func WithProducer added in v1.1.1

func WithProducer(cnf RabbitConfig, announces ...queue.BusAnnounce) Option

func WithRedis

func WithRedis(cnf RedisConfig) Option

func WithRunner

func WithRunner(name string, runner Once) Option

func WithSubscriber added in v1.3.0

func WithSubscriber(cnf RabbitConfig, setup QueueRouterSetup) Option

type Processor added in v1.11.4

type Processor func(
	context.Context,
	string,
	storage.PgStorage,
	cache.RedisCache,
	chan queue.Announce,
	chan queue.Task,
)

type Queue added in v1.3.0

type Queue struct {
	Exchange string
	Route    string
	rabbitmq.Callback
	rabbitmq.ExchangeType
}

type QueueRouterSetup added in v1.11.3

type QueueRouterSetup = func() []Queue

type RabbitConfig added in v1.1.1

type RabbitConfig struct {
	Port             uint32 `env:"RABBIT_PORT" env-default:"5672"`
	Host             string `env:"RABBIT_HOST" env-default:"localhost"`
	User             string `env:"RABBIT_USER" env-default:"guest" vault:"RABBITMQ_USERNAME"`
	Password         string `env:"RABBIT_PWD" vault:"RABBITMQ_PASSWORD"`
	VHost            string `env:"RABBIT_VHOST" env-default:"/"`
	PrefetchCount    int    `env:"RABBIT_PREFETCH_COUNT" env-default:"16"`
	PrefetchSize     int    `env:"RABBIT_PREFETCH_SIZE" env-default:"0"`
	ProducerPoolSize uint8
}

type RedisConfig

type RedisConfig struct {
	Port               uint32 `env:"REDIS_PORT" env-default:"6379"`
	Host               string `env:"REDIS_HOST" env-default:"localhost"`
	User               string `env:"REDIS_USER" env-default:"user" vault:"KEYDB_USERNAME"`
	Password           string `env:"REDIS_PWD" vault:"KEYDB_PASSWORD"`
	Db                 int    `env:"REDIS_DB" env-default:"0"`
	DisableClientCache bool
}

Directories

Path Synopsis
srv

Jump to

Keyboard shortcuts

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