sqlite_backend

package
v0.0.0-...-a1e463d Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2015 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackendName = "sqlite"
)
View Source
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 (c *Channel) IsTimeToNotifyValid() bool

func (*Channel) ShouldSendImmediately

func (c *Channel) ShouldSendImmediately() bool

func (*Channel) ShouldSendNowGivenTime

func (c *Channel) ShouldSendNowGivenTime(currentTime time.Time) bool

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

func LoadConfig(configPath string) (*Config, error)

func (*Config) Reload

func (c *Config) Reload() error

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 (*NotificationFailedtoSendToSomeSubscribers) Error

func (*NotificationFailedtoSendToSomeSubscribers) HasError

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 (*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

Jump to

Keyboard shortcuts

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