notifications

package
v0.22.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNotificationSocketFlag

func AddNotificationSocketFlag(flags *pflag.FlagSet)

func GetNotificationSocketPath

func GetNotificationSocketPath() string

func PrepareNotificationSocketPath

func PrepareNotificationSocketPath(rootDir string, socketNamePrefix string) (string, error)

A helper function that ensures the notification socket can be created in a folder that is writable only by the current user, and that the path is reasonably unique to the calling process. If the `rootDir` is empty, it will use the user's cache directory.

Types

type CleanupStartedNotification

type CleanupStartedNotification struct{}

func (*CleanupStartedNotification) Kind

type Notification

type Notification interface {
	Kind() NotificationKind
}

type NotificationKind

type NotificationKind string
const (
	NotificationKindCleanupStarted   NotificationKind = "cleanup-started"
	NotificationKindPerftraceRequest NotificationKind = "perftrace-request"

	NotificationSocketPathFlagName = "notification-socket"
)

type NotificationSource

type NotificationSource interface {
	NotifySubscribers(n Notification) error
}

NotificationSource is a thing capable of sending notifications to subscribers.

type NotificationSubscription

type NotificationSubscription interface {
	Active() bool // True if the subscription is active and receiving notifications.
}

NotificationSubscription represents a subscription to notifications.

func NewNotificationSubscription

func NewNotificationSubscription(
	lifetimeCtx context.Context,
	socketPath string,
	log logr.Logger,
	callback func(Notification),
) (NotificationSubscription, error)

NewNotificationSubscription creates a new notification subscription that will result in the callback being called whenever a notification is received from the socket.

type NotifySubscribersFunc

type NotifySubscribersFunc func(n Notification) error

func (NotifySubscribersFunc) NotifySubscribers

func (f NotifySubscribersFunc) NotifySubscribers(n Notification) error

type PerftraceRequestNotification

type PerftraceRequestNotification struct {
	Duration time.Duration
}

func (*PerftraceRequestNotification) Kind

type UnixSocketNotificationSource

type UnixSocketNotificationSource interface {
	NotificationSource
	SocketPath() string
}

func NewNotificationSource

func NewNotificationSource(lifetimeCtx context.Context, socketPath string, log logr.Logger) (UnixSocketNotificationSource, error)

Directories

Path Synopsis
Package declaration file--seems to be required to make go modules happy.
Package declaration file--seems to be required to make go modules happy.

Jump to

Keyboard shortcuts

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