notifications

package
v2.29.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WebsocketNotificationReceiptTimeMetric = "notification_websocket_receipt_time"
	SMTPNotificationReceiptTimeMetric      = "notification_smtp_receipt_time"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// User is the configuration for the user to create.
	User createusers.Config `json:"user"`

	// Roles are the roles to assign to the user.
	Roles []string `json:"roles"`

	// NotificationTimeout is how long to wait for notifications after triggering.
	NotificationTimeout time.Duration `json:"notification_timeout"`

	// DialTimeout is how long to wait for websocket connection.
	DialTimeout time.Duration `json:"dial_timeout"`

	// ExpectedNotificationsIDs is the list of notification template IDs to expect.
	ExpectedNotificationsIDs map[uuid.UUID]struct{} `json:"-"`

	Metrics *Metrics `json:"-"`

	// DialBarrier ensures all runners are connected before notifications are triggered.
	DialBarrier *sync.WaitGroup `json:"-"`

	// ReceivingWatchBarrier is the barrier for receiving users. Regular users wait on this to disconnect after receiving users complete.
	ReceivingWatchBarrier *sync.WaitGroup `json:"-"`

	// SMTPApiUrl is the URL of the SMTP mock HTTP API
	SMTPApiURL string `json:"smtp_api_url"`

	// SMTPRequestTimeout is the timeout for SMTP requests.
	SMTPRequestTimeout time.Duration `json:"smtp_request_timeout"`

	// SMTPHttpClient is the HTTP client for SMTP requests.
	SMTPHttpClient *http.Client `json:"-"`
}

func (Config) Validate

func (c Config) Validate() error

type Metrics

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

func NewMetrics

func NewMetrics(reg prometheus.Registerer) *Metrics

func (*Metrics) AddError

func (m *Metrics) AddError(action string)

func (*Metrics) RecordLatency

func (m *Metrics) RecordLatency(latency time.Duration, notificationID string, notificationType NotificationType)

type NotificationType

type NotificationType string
const (
	NotificationTypeWebsocket NotificationType = "websocket"
	NotificationTypeSMTP      NotificationType = "smtp"
)

type Runner

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

func NewRunner

func NewRunner(client *codersdk.Client, cfg Config) *Runner

func (*Runner) Cleanup

func (r *Runner) Cleanup(ctx context.Context, id string, logs io.Writer) error

func (*Runner) GetMetrics

func (r *Runner) GetMetrics() map[string]any

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, id string, logs io.Writer) error

func (*Runner) WithClock

func (r *Runner) WithClock(clock quartz.Clock) *Runner

Jump to

Keyboard shortcuts

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