notification

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PartnershipRequestEventType fires when a partner organization receives a request to establish a partnership.
	PartnershipRequestEventType = "partnership-request"

	// PartnershipResponseEventType fires when a partner organization responds to a partnership request.
	PartnershipResponseEventType = "partnership-response"

	// AssessmentSharedEventType fires when a migration assessment is shared with a partner organization.
	AssessmentSharedEventType = "assessment-shared"

	// AssessmentCreatedEventType fires when a new assessment is created on behalf of a customer by a partner organization.
	AssessmentCreatedEventType = "assessment-created"
)
View Source
const (
	SeverityImportant = "IMPORTANT"
)

Variables

This section is empty.

Functions

func Build

func Build(eventType, orgID, severity string, context map[string]string, recipients ...Recipient) ([]byte, error)

Build constructs a Notification for eventType and marshals it to JSON, ready to be stored in the outbox and later dispatched by a Writer.

Types

type Event

type Event struct {
	Metadata map[string]string `json:"metadata"`
	Payload  any               `json:"payload"`
}

type HTTPWriter

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

HTTPWriter sends notification payloads to the notification service over an mTLS-authenticated HTTPS connection.

func NewHTTPWriter

func NewHTTPWriter(notificationURL string, certPEM, keyPEM []byte) (*HTTPWriter, error)

NewHTTPWriter builds an HTTPWriter that authenticates with the notification service using the given PEM-encoded client certificate and private key.

func (*HTTPWriter) Write

func (w *HTTPWriter) Write(ctx context.Context, data []byte) error

type NoopWriter

type NoopWriter struct{}

NoopWriter discards notifications. It is used when notifications are disabled via configuration.

func NewNoopWriter

func NewNoopWriter() *NoopWriter

func (*NoopWriter) Write

func (w *NoopWriter) Write(_ context.Context, _ []byte) error

type Notification

type Notification struct {
	ID          string            `json:"id"`
	Version     string            `json:"version"`
	Bundle      string            `json:"bundle"`
	Application string            `json:"application"`
	EventType   string            `json:"event_type"`
	Timestamp   string            `json:"timestamp"`
	OrgID       string            `json:"org_id"`
	Severity    string            `json:"severity"`
	Context     map[string]string `json:"context,omitempty"`
	Events      []Event           `json:"events"`
	Recipients  []Recipient       `json:"recipients,omitempty"`
}

Notification matches the Console Notifications service message schema.

func New

func New(eventType, orgID, severity string, context map[string]string, payload any, recipients ...Recipient) Notification

New builds a Notification for eventType, stamping the fields fixed by the application's registration with the notification service (id, version, bundle, application, timestamp).

type Recipient

type Recipient struct {
	OnlyAdmins            bool     `json:"only_admins"`
	IgnoreUserPreferences bool     `json:"ignore_user_preferences"`
	Users                 []string `json:"users,omitempty"`
}

type StdoutWriter

type StdoutWriter struct{}

StdoutWriter prints notifications to stdout. It is used as a fallback when the notification service's mTLS client certificate is not configured.

func NewStdoutWriter

func NewStdoutWriter() *StdoutWriter

func (*StdoutWriter) Write

func (w *StdoutWriter) Write(_ context.Context, data []byte) error

type Writer

type Writer interface {
	Write(ctx context.Context, data []byte) error
}

Writer sends an already-built notification payload (see Build) to the notification service.

Jump to

Keyboard shortcuts

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