status

package
v0.0.52 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventStatusPublished pubsub.EventType = "status_published"
)

Variables

This section is empty.

Functions

func Debug

func Debug(message string, opts ...StatusOption)

func Error

func Error(message string, opts ...StatusOption)

func Info

func Info(message string, opts ...StatusOption)

func InitService

func InitService() error

func Subscribe

func Subscribe(ctx context.Context) <-chan pubsub.Event[StatusMessage]

func Warn

func Warn(message string, opts ...StatusOption)

Types

type Level

type Level string
const (
	LevelInfo  Level = "info"
	LevelWarn  Level = "warn"
	LevelError Level = "error"
	LevelDebug Level = "debug"
)

type Service

type Service interface {
	pubsub.Subscriber[StatusMessage]

	Info(message string, opts ...StatusOption)
	Warn(message string, opts ...StatusOption)
	Error(message string, opts ...StatusOption)
	Debug(message string, opts ...StatusOption)
}

func GetService

func GetService() Service

type StatusMessage

type StatusMessage struct {
	Level     Level         `json:"level"`
	Message   string        `json:"message"`
	Timestamp time.Time     `json:"timestamp"`
	Critical  bool          `json:"critical"`
	Duration  time.Duration `json:"duration"`
}

type StatusOption added in v0.0.49

type StatusOption func(*StatusMessage)

StatusOption is a function that configures a status message

func WithCritical added in v0.0.49

func WithCritical(critical bool) StatusOption

WithCritical marks a status message as critical, causing it to be displayed immediately

func WithDuration added in v0.0.49

func WithDuration(duration time.Duration) StatusOption

WithDuration sets a custom display duration for a status message

Jump to

Keyboard shortcuts

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