Documentation
¶
Index ¶
- type Dispatcher
- func (d *Dispatcher) Channels() []string
- func (d *Dispatcher) Notify(ctx context.Context, n pkgchannel.Notification) error
- func (d *Dispatcher) NotifyUser(ctx context.Context, userID int64, n pkgchannel.Notification) error
- func (d *Dispatcher) Register(ch pkgchannel.Channel)
- func (d *Dispatcher) SetAuthService(service pkgplugins.Auth)
- func (d *Dispatcher) SetChannelStore(store channelStore)
- func (d *Dispatcher) Unregister(name string)
- type Notifier
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 ¶
func (d *Dispatcher) Notify(ctx context.Context, n pkgchannel.Notification) error
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:
- If the notification came from an agent with a dedicated channel and the user has that platform identity, use the dedicated channel.
- If the user has a notify_identity_id preference, use that platform's non-dedicated channel.
- 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.