notification

package
v0.33.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"

	// TODO: implement the mechnisem of notify the customer when a partner creates an assessment on their behalf.
	// This is disabled because there is currently no "create on behalf of a customer"
	// 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 Config

type Config struct {
	URL                string
	ClientCert         []byte
	ClientKey          []byte
	InsecureSkipVerify bool
}

Config configures an HTTP writer for the notification service.

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(config Config) (*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"`
	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