notification

package
v0.0.0-...-e0e180f Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Notifiers is the list of configured notifiers. Set directly for testing.
	Notifiers []Notifier
)

Functions

func CalculateDiff

func CalculateDiff(pre, post string) string

func SendNotification

func SendNotification(n Notification)

SendNotification dispatches a notification to all configured notifiers asynchronously. Notifications are sent in a background goroutine and failures do not affect the caller.

func ValidateConfig

func ValidateConfig()

ValidateConfig checks notification configuration and logs warnings if misconfigured. This should be called during application startup.

Types

type ComponentType

type ComponentType string

ComponentType identifies which part of a flag was modified.

const (
	ComponentFlag         ComponentType = "flag"
	ComponentSegment      ComponentType = "segment"
	ComponentVariant      ComponentType = "variant"
	ComponentConstraint   ComponentType = "constraint"
	ComponentDistribution ComponentType = "distribution"
	ComponentTag          ComponentType = "tag"
)

type MockNotifier

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

func NewMockNotifier

func NewMockNotifier() *MockNotifier

func (*MockNotifier) ClearSent

func (m *MockNotifier) ClearSent()

func (*MockNotifier) GetSentNotifications

func (m *MockNotifier) GetSentNotifications() []Notification

func (*MockNotifier) Name

func (m *MockNotifier) Name() string

func (*MockNotifier) Send

func (m *MockNotifier) Send(ctx context.Context, n Notification) error

func (*MockNotifier) SetSendError

func (m *MockNotifier) SetSendError(err error)

type Notification

type Notification struct {
	Operation     Operation     `json:"operation"`
	FlagID        uint          `json:"flag_id"`
	FlagKey       string        `json:"flag_key"`
	ComponentType ComponentType `json:"component_type,omitempty"`
	ComponentID   uint          `json:"component_id,omitempty"`
	ComponentKey  string        `json:"component_key,omitempty"`
	PreValue      string        `json:"pre_value,omitempty"`
	PostValue     string        `json:"post_value,omitempty"`
	Diff          string        `json:"diff,omitempty"`
	User          string        `json:"user,omitempty"`
	Timestamp     time.Time     `json:"timestamp"`
}

type Notifier

type Notifier interface {
	Send(ctx context.Context, n Notification) error
	Name() string
}

func GetNotifiers

func GetNotifiers() []Notifier

GetNotifiers returns the list of configured notifiers. It initializes the notifiers on first call using sync.Once. For testing, set Notifiers directly before calling GetNotifiers.

func NewWebhookNotifier

func NewWebhookNotifier() Notifier

type Operation

type Operation string
const (
	OperationCreate  Operation = "create"
	OperationUpdate  Operation = "update"
	OperationDelete  Operation = "delete"
	OperationRestore Operation = "restore"
)

Jump to

Keyboard shortcuts

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