Documentation
¶
Index ¶
- Constants
- Variables
- func AddField(ctx context.Context, key string, value any)
- func ConfigureDatabase(config *CommonConfig) *pgxpool.Pool
- func ConfigureLogger(config *CommonConfig) *os.File
- func FlattenMap(keyMap map[string]any) []any
- func GetRandomString(n uint) string
- type CommonConfig
- type LogState
- type RequestUtils
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 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 GetRandomString ¶
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 RequestUtils ¶
type RequestUtils struct {
Logger *slog.Logger
LoggedState *LogState
RequestId uuid.UUID
UserId uuid.UUID
}
func GetValuesFromContext ¶
func GetValuesFromContext(ctx context.Context) (RequestUtils, error)
Source Files
¶
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. |
Click to show internal directories.
Click to hide internal directories.