statping: github.com/hunterlong/statping/types/notifications Index | Files

package notifications

import "github.com/hunterlong/statping/types/notifications"

Index

Package Files

database.go methods.go struct.go

func SetDB Uses

func SetDB(database database.Database)

type Notification Uses

type Notification struct {
    Id          int64         `gorm:"primary_key;column:id" json:"id"`
    Method      string        `gorm:"column:method" json:"method"`
    Host        string        `gorm:"not null;column:host" json:"host,omitempty"`
    Port        int           `gorm:"not null;column:port" json:"port,omitempty"`
    Username    string        `gorm:"not null;column:username" json:"username,omitempty"`
    Password    string        `gorm:"not null;column:password" json:"password,omitempty"`
    Var1        string        `gorm:"not null;column:var1" json:"var1,omitempty"`
    Var2        string        `gorm:"not null;column:var2" json:"var2,omitempty"`
    ApiKey      string        `gorm:"not null;column:api_key" json:"api_key,omitempty"`
    ApiSecret   string        `gorm:"not null;column:api_secret" json:"api_secret,omitempty"`
    Enabled     null.NullBool `gorm:"column:enabled;type:boolean;default:false" json:"enabled,omitempty"`
    Limits      int           `gorm:"not null;column:limits" json:"limits"`
    Removable   bool          `gorm:"column:removable" json:"removable"`
    CreatedAt   time.Time     `gorm:"column:created_at" json:"created_at"`
    UpdatedAt   time.Time     `gorm:"column:updated_at" json:"updated_at"`
    Title       string        `gorm:"-" json:"title"`
    Description string        `gorm:"-" json:"description"`
    Author      string        `gorm:"-" json:"author"`
    AuthorUrl   string        `gorm:"-" json:"author_url"`
    Icon        string        `gorm:"-" json:"icon"`
    Delay       time.Duration `gorm:"-" json:"delay,string"`
    Running     chan bool     `gorm:"-" json:"-"`

    Form  []NotificationForm `gorm:"-" json:"form"`
    Queue []RunFunc          `gorm:"-" json:"-"`

    Hits notificationHits `gorm:"-" json:"-"`
    // contains filtered or unexported fields
}

Notification contains all the fields for a Statping Notifier.

func Find Uses

func Find(method string) (*Notification, error)

func (*Notification) AfterFind Uses

func (n *Notification) AfterFind() (err error)

AfterFind for Notification will set the timezone

func (*Notification) CanSend Uses

func (n *Notification) CanSend() bool

func (*Notification) Close Uses

func (n *Notification) Close()

close will stop the go routine for queue

func (*Notification) Create Uses

func (n *Notification) Create() error

func (*Notification) GetValue Uses

func (n *Notification) GetValue(dbField string) string

GetValue returns the database value of a accept DbField value.

func (*Notification) IsRunning Uses

func (n *Notification) IsRunning() bool

IsRunning will return true if the notifier is currently running a queue

func (*Notification) LastSent Uses

func (n *Notification) LastSent() time.Duration

LastSent returns a time.Duration of the last sent notification for the notifier

func (*Notification) Logger Uses

func (n *Notification) Logger() *logrus.Logger

func (*Notification) Name Uses

func (n *Notification) Name() string

func (*Notification) Start Uses

func (n *Notification) Start()

start will start the go routine for the notifier queue

func (*Notification) Update Uses

func (n *Notification) Update() error

func (*Notification) UpdateFields Uses

func (n *Notification) UpdateFields(notif *Notification) *Notification

type NotificationForm Uses

type NotificationForm struct {
    Type        string `json:"type"`        // the html input type (text, password, email)
    Title       string `json:"title"`       // include a title for ease of use
    Placeholder string `json:"placeholder"` // add a placeholder for the input
    DbField     string `json:"field"`       // true variable key for input
    SmallText   string `json:"small_text"`  // insert small text under a html input
    Required    bool   `json:"required"`    // require this input on the html form
    IsHidden    bool   `json:"hidden"`      // hide this form element from end user
    IsList      bool   `json:"list"`        // make this form element a comma separated list
    IsSwitch    bool   `json:"switch"`      // make the notifier a boolean true/false switch
}

NotificationForm contains the HTML fields for each variable/input you want the notifier to accept.

type NotificationOrder Uses

type NotificationOrder []Notification

NotificationOrder will reorder the services based on 'order_id' (Order)

func (NotificationOrder) Len Uses

func (c NotificationOrder) Len() int

Sort interface for resorting the Notifications in order

func (NotificationOrder) Less Uses

func (c NotificationOrder) Less(i, j int) bool

func (NotificationOrder) Swap Uses

func (c NotificationOrder) Swap(i, j int)

type RunFunc Uses

type RunFunc func(interface{}) error

Package notifications imports 8 packages (graph). Updated 2020-05-30. Refresh now. Tools for package owners.