Help us shape the future of Go! Take the 2026 Go Developer Survey

notifier

package
v2.7.4 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CampfireClient

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

func NewCampfireClient

func NewCampfireClient(url string, providerClient *gophercloud.ProviderClient) *CampfireClient

func (*CampfireClient) SendEmail

func (c *CampfireClient) SendEmail(ctx context.Context, req *CampfireRequest) error

type CampfireRequest

type CampfireRequest struct {
	ProjectID  string   `json:"project_id,omitempty"`
	Recipients []string `json:"recipients,omitempty"`
	Subject    string   `json:"subject"`
	MimeType   string   `json:"mime_type"`
	MailText   string   `json:"mail_text"`
}

type Config

type Config struct {
	CampfireURL    string
	TemplatePath   string
	DigestCron     string
	ProviderClient *gophercloud.ProviderClient
}

type NotificationData

type NotificationData struct {
	Type     string // "immediate" or "digest"
	Services []ServiceInfo
}

func (NotificationData) TotalEndpoints

func (n NotificationData) TotalEndpoints() int

type Notifier

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

func New

func New(cfg Config, pool db.PgxIface) (*Notifier, error)

func (*Notifier) RunDigest

func (n *Notifier) RunDigest(ctx context.Context, pool db.PgxIface)

func (*Notifier) ScheduleImmediate

func (n *Notifier) ScheduleImmediate(pool db.PgxIface, serviceID strfmt.UUID, ep *models.Endpoint)

ScheduleImmediate creates a one-shot job that sends an immediate notification for a new pending endpoint.

The job runs asynchronously after the calling HTTP handler returns. Rather than capturing the caller's request-scoped context (which net/http cancels on handler return), the task receives a job-scoped context from gocron. That context is independent of the caller's lifetime and is cancelled when the scheduler shuts down, so in-flight tasks short-circuit cleanly on shutdown. We re-attach a bounded timeout so the DB lookup and Campfire HTTP call cannot run unbounded.

The ctx parameter is intentionally unused: it exists for API symmetry with other notifier methods and to keep the call site in controller/endpoint.go natural.

func (*Notifier) SendNotification

func (n *Notifier) SendNotification(ctx context.Context, projectID string, data NotificationData) error

func (*Notifier) Start

func (n *Notifier) Start(ctx context.Context) error

Start starts the digest notification cron job with distributed leader election.

func (*Notifier) Stop

func (n *Notifier) Stop() error

Stop stops the notification scheduler gracefully.

type PendingGroup

type PendingGroup struct {
	ProjectID string
	Services  []ServiceInfo
}

func QueryPendingEndpoints

func QueryPendingEndpoints(ctx context.Context, pool db.PgxIface) ([]PendingGroup, error)

type ServiceInfo

type ServiceInfo struct {
	models.Service
	Endpoints []*models.Endpoint
}

type Templates

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

func LoadTemplates

func LoadTemplates(overridePath string) (*Templates, error)

func (*Templates) RenderBody

func (t *Templates) RenderBody(data NotificationData) (string, error)

func (*Templates) RenderSubject

func (t *Templates) RenderSubject(data NotificationData) (string, error)

Jump to

Keyboard shortcuts

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