utils

package module
v0.0.0-...-e1fa791 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const LoggedState contextKey = "loggedState"
View Source
const Logger contextKey = "logger"
View Source
const RequestIdKey contextKey = "requestId"
View Source
const UserIdKey contextKey = "userId"

Variables

View Source
var DatabaseTimeout = 24 * time.Second

Default timeout for database operations

View Source
var ErrRequestUtils = errors.New("request does not contain expected values in context")

Functions

func AddField

func AddField(ctx context.Context, key string, value any)

func ConfigureDatabase

func ConfigureDatabase(config *CommonConfig) *pgxpool.Pool

ConfigureDatabase connects to the database url specified in the config and returns a pooled connection

func ConfigureLogger

func ConfigureLogger(config *CommonConfig) *os.File

ConfigureLogger configures slog to production or development levels as specified in the given config.

func FlattenMap

func FlattenMap(keyMap map[string]any) []any

func GetRandomString

func GetRandomString(n uint) string

GetRandomString returns a string of length n containing random ASCII letters (A–Z, a–z) selected from the package alphabet. If n is zero, an empty string is returned.

Types

type CommonConfig

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

Config loaded from env to configure application behavior

func LoadConfig

func LoadConfig() *CommonConfig

LoadConfig loads the configuration from the environment variables

type LogState

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

func (*LogState) Snapshot

func (l *LogState) Snapshot() map[string]any

type RequestUtils

type RequestUtils struct {
	Logger      *slog.Logger
	LoggedState *LogState
	RequestId   uuid.UUID
	UserId      uuid.UUID
}

func GetValuesFromContext

func GetValuesFromContext(ctx context.Context) (RequestUtils, error)

Directories

Path Synopsis
rabbitmqnotifications contains definitions for the persistent RabbitMQ entities, and a utility function to declare them.
rabbitmqnotifications contains definitions for the persistent RabbitMQ entities, and a utility function to declare them.

Jump to

Keyboard shortcuts

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