notificationsflags

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmailEnabledID       = "notifications/1"
	DigestFrequencyID    = "notifications/2"
	MaxRetriesID         = "notifications/3"
	ScoreThresholdID     = "notifications/4"
	NotificationEmailsID = "notifications/5"
	RetryDelaysID        = "notifications/6"
)

Flag ID constants. Format: feature_id/field_number.

View Source
const (
	EmailEnabledDefault    = true
	DigestFrequencyDefault = "daily"
	MaxRetriesDefault      = int64(3)
	ScoreThresholdDefault  = float64(0.75)
)

Compiled defaults from proto annotations.

View Source
const FeatureID = "notifications"

Variables

View Source
var FlagDescriptors = []flagmeta.FlagDescriptor{
	{
		ID: EmailEnabledID, FieldName: "email_enabled",
		Type:        flagmeta.FlagTypeBool,
		DefaultBool: EmailEnabledDefault,
	},
	{
		ID: DigestFrequencyID, FieldName: "digest_frequency",
		Type:          flagmeta.FlagTypeString,
		DefaultString: DigestFrequencyDefault,
	},
	{
		ID: MaxRetriesID, FieldName: "max_retries",
		Type:         flagmeta.FlagTypeInt64,
		DefaultInt64: MaxRetriesDefault,
	},
	{
		ID: ScoreThresholdID, FieldName: "score_threshold",
		Type:          flagmeta.FlagTypeDouble,
		DefaultDouble: ScoreThresholdDefault,
	},
	{
		ID: NotificationEmailsID, FieldName: "notification_emails",
		Type: flagmeta.FlagTypeString, IsList: true,
		DefaultStrings: NotificationEmailsDefault(),
	},
	{
		ID: RetryDelaysID, FieldName: "retry_delays",
		Type: flagmeta.FlagTypeInt64, IsList: true,
		DefaultInt64s: RetryDelaysDefault(),
	},
}

FlagDescriptors provides structured metadata about each flag in this feature. Use it to iterate over all flags for documentation, admin UIs, generic test helpers, or override validation.

Functions

func NotificationEmailsDefault

func NotificationEmailsDefault() []string

NotificationEmailsDefault returns the compiled default for NotificationEmails.

func RetryDelaysDefault

func RetryDelaysDefault() []int64

RetryDelaysDefault returns the compiled default for RetryDelays.

Types

type NotificationsFlags

type NotificationsFlags interface {
	EmailEnabled(ctx context.Context) bool
	DigestFrequency(ctx context.Context) string
	MaxRetries(ctx context.Context) int64
	ScoreThreshold(ctx context.Context) float64
	NotificationEmails(ctx context.Context) []string
	RetryDelays(ctx context.Context) []int64
}

NotificationsFlags provides type-safe access to notifications feature flags.

func Defaults

func Defaults() NotificationsFlags

Defaults returns a NotificationsFlags that always returns the compiled default for every flag. Use this when no evaluator is available to avoid nil checks at call sites.

func New added in v0.15.0

New creates a NotificationsFlags client backed by a pbflags.Evaluator. By default, evaluation errors are logged via slog.Default(). Use flagmeta.WithLogger to override.

func NewNotificationsFlagsClient deprecated

func NewNotificationsFlagsClient(eval pbflags.Evaluator, opts ...flagmeta.Option) NotificationsFlags

NewNotificationsFlagsClient is a deprecated alias for New.

Deprecated: Use New instead.

type TestNotificationsFlags

type TestNotificationsFlags struct {
	EmailEnabledFunc       func(context.Context) bool
	DigestFrequencyFunc    func(context.Context) string
	MaxRetriesFunc         func(context.Context) int64
	ScoreThresholdFunc     func(context.Context) float64
	NotificationEmailsFunc func(context.Context) []string
	RetryDelaysFunc        func(context.Context) []int64
}

TestNotificationsFlags is a mutable implementation of NotificationsFlags for use in tests. Each method delegates to its corresponding Func field, which is pre-populated with the compiled default. Override individual fields to stub specific flags.

func Testing

func Testing() *TestNotificationsFlags

Testing returns a mutable NotificationsFlags whose func fields are pre-populated with compiled defaults. Override individual Func fields to stub specific flags without implementing the entire interface.

func (*TestNotificationsFlags) DigestFrequency

func (t *TestNotificationsFlags) DigestFrequency(ctx context.Context) string

func (*TestNotificationsFlags) EmailEnabled

func (t *TestNotificationsFlags) EmailEnabled(ctx context.Context) bool

func (*TestNotificationsFlags) MaxRetries

func (t *TestNotificationsFlags) MaxRetries(ctx context.Context) int64

func (*TestNotificationsFlags) NotificationEmails

func (t *TestNotificationsFlags) NotificationEmails(ctx context.Context) []string

func (*TestNotificationsFlags) RetryDelays

func (t *TestNotificationsFlags) RetryDelays(ctx context.Context) []int64

func (*TestNotificationsFlags) ScoreThreshold

func (t *TestNotificationsFlags) ScoreThreshold(ctx context.Context) float64

Jump to

Keyboard shortcuts

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