Documentation ¶
Index ¶
- Constants
- type Channel
- type Config
- type ConfigJSON
- type Notification
- type NotificationFailedtoSendToSomeSubscribers
- type SQLiteNotificationBackend
- func (b *SQLiteNotificationBackend) BlockUntilReady()
- func (b *SQLiteNotificationBackend) ForceConfigReload()
- func (b *SQLiteNotificationBackend) ForceNotificationDelivery()
- func (b *SQLiteNotificationBackend) GetChannelAndItsSubscribers(channelName string) (*Channel, []backend.Subscriber)
- func (b *SQLiteNotificationBackend) GetChannels() []*Channel
- func (b *SQLiteNotificationBackend) GetSubscribers() []backend.Subscriber
- func (b *SQLiteNotificationBackend) Initialize(openString string) error
- func (b *SQLiteNotificationBackend) Name() string
- func (b *SQLiteNotificationBackend) QueueNotification(notification backend.Notification) error
- func (b *SQLiteNotificationBackend) Shutdown()
- func (b *SQLiteNotificationBackend) Start(wg *sync.WaitGroup)
Constants ¶
const (
BackendName = "sqlite"
)
const (
ChannelSendImmediately = "@immediately"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Name string Subscribers []string // a list of unique names as specified by the users field Notifiers []string TimeToNotify string }
func (*Channel) IsTimeToNotifyValid ¶
func (*Channel) ShouldSendImmediately ¶
type Config ¶
type Config struct { // Config has a lock for when it is reloaded, we would like to lock it. // Lock should occur when we find channels and its subscribers as well, when // we want to send messages. *sync.Mutex ConfigPath string Channels map[string]*Channel Subscribers map[string]backend.Subscriber }
func LoadConfig ¶
type ConfigJSON ¶
type ConfigJSON struct { Channels []*Channel Subscribers []backend.Subscriber }
type Notification ¶
type Notification struct { Id int64 `db:"id"` TagsString string PriorityInt int64 Delivered bool backend.Notification }
func (*Notification) PostGet ¶
func (n *Notification) PostGet(s gorp.SqlExecutor) error
func (*Notification) PreInsert ¶
func (n *Notification) PreInsert(s gorp.SqlExecutor) error
func (*Notification) PreUpdate ¶
func (n *Notification) PreUpdate(s gorp.SqlExecutor) error
type NotificationFailedtoSendToSomeSubscribers ¶
type NotificationFailedtoSendToSomeSubscribers struct { Errors map[string]error // subscriber unique name to error Notifications []*Notification }
func NewNotificationFailedToSendToSubscribersError ¶
func NewNotificationFailedToSendToSubscribersError(notifications []*Notification) *NotificationFailedtoSendToSomeSubscribers
func (*NotificationFailedtoSendToSomeSubscribers) AddError ¶
func (err *NotificationFailedtoSendToSomeSubscribers) AddError(name string, e error)
func (*NotificationFailedtoSendToSomeSubscribers) Error ¶
func (err *NotificationFailedtoSendToSomeSubscribers) Error() string
func (*NotificationFailedtoSendToSomeSubscribers) HasError ¶
func (err *NotificationFailedtoSendToSomeSubscribers) HasError() bool
type SQLiteNotificationBackend ¶
type SQLiteNotificationBackend struct { *gorp.DbMap // Set this if you are embedding this struct directly or via a variable // as you just want to use the web to show a dashboard and want to use // maybe another way to send notifications. NeverSendNotifications bool // contains filtered or unexported fields }
func (*SQLiteNotificationBackend) BlockUntilReady ¶
func (b *SQLiteNotificationBackend) BlockUntilReady()
func (*SQLiteNotificationBackend) ForceConfigReload ¶
func (b *SQLiteNotificationBackend) ForceConfigReload()
func (*SQLiteNotificationBackend) ForceNotificationDelivery ¶
func (b *SQLiteNotificationBackend) ForceNotificationDelivery()
func (*SQLiteNotificationBackend) GetChannelAndItsSubscribers ¶
func (b *SQLiteNotificationBackend) GetChannelAndItsSubscribers(channelName string) (*Channel, []backend.Subscriber)
Gets the channel and its subscribers.
This function guarentees that both channels and subscribers are from one version of the config, but it does not guarentee that this happens.
func (*SQLiteNotificationBackend) GetChannels ¶
func (b *SQLiteNotificationBackend) GetChannels() []*Channel
When using this function in combination with GetSubscribers(), there is no guarentee that the two lists are not coming from two different versions of the configuration.
There is no public methods for getting them under one version.
func (*SQLiteNotificationBackend) GetSubscribers ¶
func (b *SQLiteNotificationBackend) GetSubscribers() []backend.Subscriber
func (*SQLiteNotificationBackend) Initialize ¶
func (b *SQLiteNotificationBackend) Initialize(openString string) error
Initializes a new instance of the backend
This function must be called once only after getting a backend as per the NotificationBackend specification.
The openString format is as follows:
<db_file_path>,<config_file_path>
func (*SQLiteNotificationBackend) Name ¶
func (b *SQLiteNotificationBackend) Name() string
func (*SQLiteNotificationBackend) QueueNotification ¶
func (b *SQLiteNotificationBackend) QueueNotification(notification backend.Notification) error
The algorithm of this function goes as follows:
0. Ensure the channel exists 1. Save it regardless of what happens. 2. Check if the backend disabled sending of notifications 3. See if the channel should send immediately. 4. If yes, send the notification, otherwise don't.
func (*SQLiteNotificationBackend) Shutdown ¶
func (b *SQLiteNotificationBackend) Shutdown()
func (*SQLiteNotificationBackend) Start ¶
func (b *SQLiteNotificationBackend) Start(wg *sync.WaitGroup)