utils

package
v0.0.0-...-86af94f Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: AGPL-3.0 Imports: 9 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

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 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

Jump to

Keyboard shortcuts

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