common

package module
v0.0.0-...-5609e71 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectPGXPool

func ConnectPGXPool(ctx context.Context, databaseURL string, logLevel string) (*pgxpool.Pool, error)

func ConnectPGXPoolWithRetry

func ConnectPGXPoolWithRetry(ctx context.Context, databaseURL string, logLevel string, attempts int, delay time.Duration) (*pgxpool.Pool, error)

func GetenvOrDefault

func GetenvOrDefault(key, defaultValue string) string

func GetenvOrDefaultInt

func GetenvOrDefaultInt(key, defaultValue string) int

func InitSlog

func InitSlog() string

func KgoLogLevelFromString

func KgoLogLevelFromString(levelStr string) kgo.LogLevel

func NewPgxTracer

func NewPgxTracer(levelStr string) *tracelog.TraceLog

func RequireEnv

func RequireEnv(key string) string

func SetupEchoDefaults

func SetupEchoDefaults(e *echo.Echo, subsystem string, healthHandler echo.HandlerFunc, readyHandler echo.HandlerFunc)

func SplitCommaSeparated

func SplitCommaSeparated(raw string) []string

Types

type Event

type Event struct {
	Id        string         `json:"id"`
	Timestamp time.Time      `json:"timestamp"`
	Source    string         `json:"source"`
	Severity  Severity       `json:"severity"`
	Type      string         `json:"type"`
	Payload   map[string]any `json:"payload,omitempty"`
}

func (*Event) Enrich

func (e *Event) Enrich()

func (*Event) Validate

func (e *Event) Validate() error

type EventSummary

type EventSummary struct {
	BucketStart  time.Time      `json:"bucket_start"`
	BucketEnd    time.Time      `json:"bucket_end"`
	TotalCount   int            `json:"total_count"`
	BySeverity   map[string]int `json:"by_severity"`
	ByType       map[string]int `json:"by_type"`
	SampleEvents []Event        `json:"sample_events,omitempty"`
}

type KgoSlogLogger

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

func NewKgoSlogLogger

func NewKgoSlogLogger(logger *slog.Logger, level kgo.LogLevel) *KgoSlogLogger

func (*KgoSlogLogger) Level

func (l *KgoSlogLogger) Level() kgo.LogLevel

func (*KgoSlogLogger) Log

func (l *KgoSlogLogger) Log(level kgo.LogLevel, msg string, keyvals ...any)

type Severity

type Severity int
const (
	SeverityInfo Severity = iota
	SeverityWarn
	SeverityErr
	SeverityCritical
)

func ParseSeverity

func ParseSeverity(s string) (Severity, error)

func (Severity) String

func (i Severity) String() string

type TimeRange

type TimeRange struct {
	Start time.Time `json:"start"`
	End   time.Time `json:"end"`
}

func (*TimeRange) Validate

func (r *TimeRange) Validate() error

Jump to

Keyboard shortcuts

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