notify

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

Dispatcher routes notifications to one or more registered channels. It implements Notifier so it can be passed to tools and scheduler wiring.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates an empty dispatcher. Register channels before use.

func (*Dispatcher) Channels

func (d *Dispatcher) Channels() []string

Channels returns the names of all registered channels.

func (*Dispatcher) Notify

Notify routes a notification to channels. If Notification.Channel is set, only that channel receives it. Otherwise all registered channels receive it.

func (*Dispatcher) NotifyUser

func (d *Dispatcher) NotifyUser(ctx context.Context, userID int64, n pkgchannel.Notification) error

NotifyUser sends a notification to a specific user via a single channel.

Resolution order:

  1. If the notification came from an agent with a dedicated channel and the user has that platform identity, use the dedicated channel.
  2. If the user has a notify_identity_id preference, use that platform's non-dedicated channel.
  3. Otherwise use the first linked identity with a non-dedicated channel.

Falls back to broadcast if the user has no linked identities or if no auth store is configured.

func (*Dispatcher) Register

func (d *Dispatcher) Register(ch pkgchannel.Channel)

Register adds a channel to the dispatcher.

func (*Dispatcher) SetAuthService

func (d *Dispatcher) SetAuthService(service pkgplugins.Auth)

SetAuthService configures the auth directory for per-user notification routing.

func (*Dispatcher) SetChannelStore added in v0.10.0

func (d *Dispatcher) SetChannelStore(store channelStore)

SetChannelStore configures the channel directory for agent-bound routing.

func (*Dispatcher) Unregister

func (d *Dispatcher) Unregister(name string)

Unregister removes all channels with the given name from the dispatcher.

type Notifier

type Notifier interface {
	Notify(ctx context.Context, n pkgchannel.Notification) error
}

Notifier can push notifications. Both Dispatcher and individual channels satisfy this interface, so consumers don't need to know the routing layer.

Jump to

Keyboard shortcuts

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