utils

package
v0.0.0-...-9f1173d Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureError

func CaptureError(err error)

func CaptureErrorResult

func CaptureErrorResult(errResult AnyResult)

func CaptureErrorResultWithExtra

func CaptureErrorResultWithExtra(errResult AnyResult, extraKey string, extraValue any)

func GetEnvAsBool

func GetEnvAsBool(key string, defaultValue bool) bool

func GetEnvAsInt

func GetEnvAsInt(key string, defaultValue int) (int, error)

func GetEnvOrDefault

func GetEnvOrDefault(key string, defaultValue string) string

func LogAndPanic

func LogAndPanic(err error, message string)

func ParseBrokersEnv

func ParseBrokersEnv(brokersStr string) []string

func StringPtr

func StringPtr(s string) *string

func TimePtr

func TimePtr(t time.Time) *time.Time

func UnmarshalNestedJSON

func UnmarshalNestedJSON(data []byte, v interface{}) error

UnmarshalNestedJSON handles JSON tags with dot notation (eg. "value.property") It supports extracting nested fields from parent objects during unmarshaling

Types

type AnyResult

type AnyResult interface {
	Success() bool
	Failure() bool
	Error() error
	ErrorMsg() string
	ErrorCode() string
	ErrorMessage() string
	IsCapturable() bool
	IsRetryable() bool
}

type CustomTime

type CustomTime time.Time

func (CustomTime) MarshalJSON

func (ct CustomTime) MarshalJSON() ([]byte, error)

func (CustomTime) String

func (ct CustomTime) String() string

func (CustomTime) Time

func (ct CustomTime) Time() time.Time

func (*CustomTime) UnmarshalJSON

func (ct *CustomTime) UnmarshalJSON(b []byte) error

type ErrorDetails

type ErrorDetails struct {
	Code    string
	Message string
}

type LevelHandler

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

LevelHandler wraps a slog.Handler and enforces a minimum log level, regardless of the underlying handler's level.

func NewLevelHandler

func NewLevelHandler(level slog.Leveler, handler slog.Handler) *LevelHandler

func (*LevelHandler) Enabled

func (h *LevelHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*LevelHandler) Handle

func (h *LevelHandler) Handle(ctx context.Context, r slog.Record) error

func (*LevelHandler) WithAttrs

func (h *LevelHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*LevelHandler) WithGroup

func (h *LevelHandler) WithGroup(name string) slog.Handler

type NullTime

type NullTime struct {
	sql.NullTime
}

func NewNullTime

func NewNullTime(t time.Time) NullTime

func NowNullTime

func NowNullTime() NullTime

func (*NullTime) MarshalJSON

func (nt *NullTime) MarshalJSON() ([]byte, error)

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

func (*NullTime) UnmarshalJSON

func (nt *NullTime) UnmarshalJSON(data []byte) error

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

type Result

type Result[T any] struct {
	Retryable bool
	Capture   bool
	// contains filtered or unexported fields
}

func FailedBoolResult

func FailedBoolResult(err error) Result[bool]

func FailedResult

func FailedResult[T any](err error) Result[T]

func SuccessResult

func SuccessResult[T any](value T) Result[T]

func ToFloat64Timestamp

func ToFloat64Timestamp(timeValue any) Result[float64]

func ToTime

func ToTime(timestamp any) Result[time.Time]

func (Result[T]) AddErrorDetails

func (r Result[T]) AddErrorDetails(code string, message string) Result[T]

func (Result[T]) Error

func (r Result[T]) Error() error

func (Result[T]) ErrorCode

func (r Result[T]) ErrorCode() string

func (Result[T]) ErrorDetails

func (r Result[T]) ErrorDetails() *ErrorDetails

func (Result[T]) ErrorMessage

func (r Result[T]) ErrorMessage() string

func (Result[T]) ErrorMsg

func (r Result[T]) ErrorMsg() string

func (Result[T]) Failure

func (r Result[T]) Failure() bool

func (Result[T]) IsCapturable

func (r Result[T]) IsCapturable() bool

func (Result[T]) IsRetryable

func (r Result[T]) IsRetryable() bool

func (Result[T]) NonCapturable

func (r Result[T]) NonCapturable() Result[T]

func (Result[T]) NonRetryable

func (r Result[T]) NonRetryable() Result[T]

func (Result[T]) Success

func (r Result[T]) Success() bool

func (Result[T]) Value

func (r Result[T]) Value() T

func (Result[T]) ValueOrPanic

func (r Result[T]) ValueOrPanic() T

type StringArray

type StringArray []string

func (StringArray) MarshalJSON

func (a StringArray) MarshalJSON() ([]byte, error)

func (*StringArray) Scan

func (a *StringArray) Scan(value any) error

func (*StringArray) UnmarshalJSON

func (a *StringArray) UnmarshalJSON(data []byte) error

func (StringArray) Value

func (a StringArray) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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