Documentation ¶
Index ¶
Constants ¶
View Source
const ( // StatusUnknown indicates that the status of the site is not yet known. StatusUnknown = 0 // StatusUp indicates that the website is responding to requests. StatusUp = 1 // StatusDown indicates that the website is not responding to requests. StatusDown = 2 )
Variables ¶
This section is empty.
Functions ¶
func FilteredError ¶
FilteredError filters the Error value by ignoring RecordNotFound errors.
Types ¶
type Conn ¶
Conn represents a connection to the database.
type Outage ¶
type Outage struct { ID int64 `json:"id"` // Start and ending time of the outage (may be 0 if ongoing) StartTime time.Time `gorm:"not null" json:"start-time"` EndTime *time.Time `json:"end-time"` // Whether the two notifications have been sent yet or not StartNotificationSent bool `gorm:"not null" json:"-"` EndNotificationSent bool `gorm:"not null" json:"-"` // Information about the error Description string `gorm:"not null" json:"description"` // Site that is experiencing the outage Site *Site `gorm:"ForeignKey:SiteID" json:"-"` SiteID int64 `sql:"type:int REFERENCES sites(id) ON DELETE CASCADE" json:"site-id"` }
Outage represents a period of time during which a site was inaccessible.
type Site ¶
type Site struct { ID int64 `json:"id"` // URL to poll and a descriptive name for the site URL string `gorm:"not null" json:"url"` Name string `gorm:"not null" json:"name"` // Poll interval and the time of last and next poll PollInterval int64 `gorm:"not null" json:"poll-interval"` LastPoll *time.Time `json:"last-poll"` NextPoll *time.Time `json:"next-poll"` // Current status of the site and the time since it last changed Status int `gorm:"not null" json:"status"` StatusTime *time.Time `json:"status-time"` // User that created the site User *User `gorm:"ForeignKey:UserID" json:"-"` UserID int64 `sql:"type:int REFERENCES users(id) ON DELETE CASCADE" json:"user-id"` }
Site represents a website being monitored.
type User ¶
type User struct { ID int64 `json:"id"` Username string `gorm:"not null" json:"username"` Password string `gorm:"not null" json:"-"` IsAdmin bool `gorm:"not null" json:"is-admin"` }
User represents a user that can login and make changes to the site configuration. Administrators can also manage users.
func (*User) Authenticate ¶
Authenticate hashes the password and compares it to the value stored in the database. An error is returned if the values do not match.
func (*User) SetPassword ¶
SetPassword salts and hashes the user's password. It does not store the new value in the database.
Click to show internal directories.
Click to hide internal directories.