notifications

package
v3.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ReaperJobName = "notifications.reaper"

ReaperJobName is the rjobs periodic job name for accumulator recovery.

Variables

This section is empty.

Functions

func DecodeEvent

func DecodeEvent(event *gateway.Event) (recipients []string, templateData map[string]any, err error)

DecodeEvent extracts the recipients and template data a producer packed into the event with EncodeEvent. It is the inverse of EncodeEvent; the event type is read directly from the event and the identities are resolved by the gateway from the request context.

func EncodeEvent

func EncodeEvent(eventType string, recipients []string, templateData map[string]any) *gateway.Event

EncodeEvent packs a notification into a CS3 gateway event. The sender and the submitting user are intentionally absent: the gateway derives them from the authenticated request context, and the CS3 API forbids callers from supplying them.

func RegisterReaperJob

func RegisterReaperJob(reaper *Reaper) error

RegisterReaperJob registers the accumulator reaper with Reva's jobs framework. The job runs on every node because lease acquisition is already SQL-coordinated and each node must be able to recover work after a local notification worker dies.

func UserIDString

func UserIDString(id *userpb.UserId) string

UserIDString renders a user id as the stable identifier used to attribute notifications to their submitter.

Types

type NoopPreferenceResolver

type NoopPreferenceResolver struct{}

NoopPreferenceResolver applies no recipient preference changes.

func (NoopPreferenceResolver) ResolveHandlers

func (NoopPreferenceResolver) ResolveHandlers(_ context.Context, _ model.Envelope, handlers []string) ([]string, error)

ResolveHandlers implements PreferenceResolver.

type PreferenceResolver

type PreferenceResolver interface {
	ResolveHandlers(ctx context.Context, envelope model.Envelope, handlers []string) ([]string, error)
}

PreferenceResolver narrows the configured handler set for a recipient set.

type Reaper

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

Reaper periodically recovers accumulated event groups that are unleased or have an expired lease.

func NewReaper

func NewReaper(worker *Worker, conf ReaperConfig) *Reaper

NewReaper creates a reaper for the given worker.

func (*Reaper) Run

func (r *Reaper) Run(ctx context.Context) error

Run performs one reaper pass. The first pass waits for a random duration in [0, interval) so boxes spread their startup scans over time.

func (*Reaper) RunOnce

func (r *Reaper) RunOnce(ctx context.Context) error

RunOnce performs one recovery scan.

type ReaperConfig

type ReaperConfig struct {
	Interval time.Duration
	Limit    int
}

ReaperConfig configures the accumulator reaper.

type Worker

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

Worker handles notification envelopes consumed from NATS.

func NewWorker

func NewWorker(store accumulation.Store, dispatcher *handlers.Dispatcher, conf WorkerConfig) (*Worker, error)

NewWorker creates a notification worker.

func (*Worker) Flush

func (w *Worker) Flush(ctx context.Context, dedupKey string) error

Flush dispatches the currently pending items for a dedup key if this worker owns the lease and the bucket is due.

func (*Worker) Handle

func (w *Worker) Handle(ctx context.Context, envelope model.Envelope) error

Handle handles one notification envelope.

type WorkerConfig

type WorkerConfig struct {
	OwnerID          string
	EventRules       map[string]model.EventRule
	Preferences      PreferenceResolver
	LeaseDuration    time.Duration
	MaxRenderedItems int
}

WorkerConfig configures a notification worker.

Directories

Path Synopsis
Package accumulation stores accepted notification events that share a deduplication key and coordinates, through an expiring lease, which box flushes them.
Package accumulation stores accepted notification events that share a deduplication key and coordinates, through an expiring lease, which box flushes them.

Jump to

Keyboard shortcuts

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