Documentation
¶
Overview ¶
Package notifychannel persists the operator's notification channels: the PostgreSQL store behind notification.ChannelStore.
It sits beside notifyprefs and notifyqueue, and is the same kind of thing: one table, read and written through one contract. The transports a channel delivers over are internal/notification/notifypost, which this package does not import and does not know about.
Index ¶
- Variables
- type PostgresStore
- func (s *PostgresStore) Delete(ctx context.Context, name string) error
- func (s *PostgresStore) Get(ctx context.Context, name string) (*notification.Channel, error)
- func (s *PostgresStore) List(ctx context.Context) ([]notification.Channel, error)
- func (s *PostgresStore) Set(ctx context.Context, ch notification.Channel) error
Constants ¶
This section is empty.
Variables ¶
var ErrChannelNotFound = errors.New("notifychannel: channel not found")
ErrChannelNotFound is returned by Get for a name no channel is stored under, and by the worker when a queued row names a channel the operator has since deleted.
Functions ¶
This section is empty.
Types ¶
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore implements notification.ChannelStore over the notification_channels table.
func NewPostgresStore ¶
func NewPostgresStore(db *sql.DB) *PostgresStore
NewPostgresStore creates a PostgreSQL-backed channel store.
func (*PostgresStore) Delete ¶
func (s *PostgresStore) Delete(ctx context.Context, name string) error
Delete removes a channel. Deleting an absent channel is not an error: the administrator asked for it to be gone and it is.
func (*PostgresStore) Get ¶
func (s *PostgresStore) Get(ctx context.Context, name string) (*notification.Channel, error)
Get returns one channel, or ErrChannelNotFound.
func (*PostgresStore) List ¶
func (s *PostgresStore) List(ctx context.Context) ([]notification.Channel, error)
List returns every channel in name order.
func (*PostgresStore) Set ¶
func (s *PostgresStore) Set(ctx context.Context, ch notification.Channel) error
Set creates or replaces a channel. created_by is preserved on an update: the administrator who created a channel stays recorded when a later one edits it, which is what the settings card reports.