core

package
v0.0.0-...-e15a062 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: CC0-1.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ServiceVersion = "UNSET"

The value of the ServiceVersion attribute associated with the otel Resource. This should be overwritten at build time:

export SERVICE_VERSION=$(git rev-parse --short HEAD)
go build -o out \
  -X verification-service-api/pkg/core.ServiceVersion=${SERVICE_VERSION}

Functions

func LoadEnv

func LoadEnv(environment ...string) error

func NewLogger

func NewLogger(cfg *Config) *slog.Logger

func NewLoggerWithOtel

func NewLoggerWithOtel(cfg *Config, otel OtelService) *slog.Logger

func WithCognitoAppClientID

func WithCognitoAppClientID(appClientID string) func(*Config)

func WithCognitoRegion

func WithCognitoRegion(region string) func(*Config)

func WithCognitoUserPoolID

func WithCognitoUserPoolID(userPoolID string) func(*Config)

func WithEnvironment

func WithEnvironment(environment string) func(*Config)

func WithOtelDisable

func WithOtelDisable(value ...bool) func(*Config)

func WithOtlpEndpoint

func WithOtlpEndpoint(endpoint string) func(*Config)

func WithOtlpInsecure

func WithOtlpInsecure(insecure bool) func(*Config)

func WithPort

func WithPort(port int) func(*Config)

func WithRedisAddr

func WithRedisAddr(addr string) func(*Config)

func WithRedisDB

func WithRedisDB(db int) func(*Config)

func WithRedisPassword

func WithRedisPassword(pw string) func(*Config)

func WithSkipAuth

func WithSkipAuth(value ...bool) func(*Config)

Types

type CognitoConfig

type CognitoConfig struct {
	Region      string
	UserPoolID  string
	AppClientID string
}

type Config

type Config struct {
	Cognito     CognitoConfig
	Environment string
	Otel        OtelConfig
	Port        int
	SkipAuth    bool
	Redis       RedisConfig
}

func DefaultConfig

func DefaultConfig() Config

func NewConfig

func NewConfig(options ...func(*Config)) Config

func NewConfigFromEnv

func NewConfigFromEnv(options ...func(*Config)) (Config, error)

func (*Config) IsProd

func (c *Config) IsProd() bool

type OtelConfig

type OtelConfig struct {
	OtlpExporter OtlpConfig
	Disable      bool
}

type OtelService

type OtelService interface {
	// Return the current span associated with context c.
	SpanFromContext(c context.Context) trace.Span
	// Return the underlying LoggerProvider
	LoggerProvider() log.LoggerProvider
	// Cleanup any resources associated with this object. Errors
	// are logged with logger.Error or logger.ErrorContext and
	// then dismissed.
	Shutdown(c context.Context, logger *slog.Logger)
}

OtelService provides methods for handling OpenTelemetry operations.

func NewOtelService

func NewOtelService(ctx context.Context, cfg *Config) (OtelService, error)

Initialize the appropriate implementation of OtelService. If cfg.Disabled then the implementation uses the otel/*/noop packages.

type OtlpConfig

type OtlpConfig struct {
	Endpoint string
	Insecure bool
}

type RedisConfig

type RedisConfig struct {
	Addr     string
	Password string
	DB       int
}

Jump to

Keyboard shortcuts

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