Documentation ¶
Index ¶
- Variables
- func CompareSites(s1 Site, s2 Site) bool
- func GetReportYears(db *sql.DB) ([]int, error)
- func GetYTDReports(db *sql.DB, year int) (map[string]Reports, error)
- func InitializeDB(dbPath string, seedFile string) (*sql.DB, error)
- func InitializeReportDB() (*sql.DB, error)
- func InitializeTestDB(seedFile string) (*sql.DB, error)
- type Contact
- type Contacts
- type Ping
- type Report
- type Reports
- type Site
- func (s Site) AddContactToSite(db *sql.DB, contactID int64) error
- func (s *Site) CreateSite(db *sql.DB) error
- func (s *Site) GetFirstPing(db *sql.DB) (time.Time, error)
- func (s *Site) GetSite(db *sql.DB, siteID int64) error
- func (s *Site) GetSiteContacts(db *sql.DB, siteID int64) error
- func (s *Site) GetSitePings(db *sql.DB, siteID int64, startTime time.Time, endTime time.Time) error
- func (s Site) RemoveContactFromSite(db *sql.DB, contactID int64) error
- func (s *Site) UpdateSite(db *sql.DB) error
- func (s *Site) UpdateSiteFirstPing(db *sql.DB, firstPingTime time.Time) error
- func (s *Site) UpdateSiteStatus(db *sql.DB, isSiteUp bool) error
- type Sites
Constants ¶
This section is empty.
Variables ¶
var Seed struct { Sites []Site Contacts []Contact }
Seed represents the initial seed to the DB.~
Functions ¶
func CompareSites ¶ added in v1.3.0
CompareSites is set up as function due to an issue in the DeepEqual with zero dates.
func GetReportYears ¶ added in v1.3.1
GetReportYears returns the years where there is data for reports
func GetYTDReports ¶
GetYTDReports gets reports for the active sites. Site status is based on the SiteDown flag in the pings table.
func InitializeDB ¶
InitializeDB creates the DB file and the schema if the file doesn't exist.
func InitializeReportDB ¶
InitializeReportDB is for test packages to initialize a Report DB for integration testing.
Types ¶
type Contact ¶
type Contact struct { ContactID int64 Name string EmailAddress string SmsNumber string SmsActive bool EmailActive bool SiteCount int Sites []Site }
Contact is one of the contacts for a particular site.
func (*Contact) CreateContact ¶
CreateContact inserts a new contact in the DB.
func (*Contact) DeleteContact ¶ added in v1.1.0
DeleteContact deletes the contact from the DB.
func (*Contact) GetContact ¶
GetContact gets the contact details for a given contact.
func (*Contact) GetContactSites ¶ added in v1.2.0
GetContactSites gets the collection of sites for a given contact.
type Contacts ¶
type Contacts []Contact
Contacts is a slice of contacts that aren't necessarily associated with a given site.
type Ping ¶
type Ping struct { SiteID int64 TimeRequest time.Time Duration int HTTPStatusCode int SiteDown bool }
Ping contains information about a request to ping a site and details about the result
type Report ¶
Report contains information about performance where AvgResponse is the average response time for successful requests, PingsUp are the number of successful pings when the site was up and PingsDown is the number of pings when the site was down.
type Reports ¶
type Reports []Report
Reports is a slice of reports, usually the index will represent the month.
type Site ¶
type Site struct { SiteID int64 Name string IsActive bool URL string PingIntervalSeconds int TimeoutSeconds int IsSiteUp bool ContentExpected string ContentUnexpected string LastStatusChange time.Time LastPing time.Time FirstPing time.Time Contacts []Contact Pings []Ping }
Site is the website that will be monitored.
func (Site) AddContactToSite ¶
AddContactToSite associates a contact with a site.
func (*Site) CreateSite ¶
CreateSite inserts a new site in the DB.
func (*Site) GetFirstPing ¶
GetFirstPing gets the earliest ping for a given site based on the recorded pings.
func (*Site) GetSiteContacts ¶
GetSiteContacts gets the collection of contacts for a given site.
func (*Site) GetSitePings ¶
GetSitePings gets the pings for a given site for a given time interval.
func (Site) RemoveContactFromSite ¶
RemoveContactFromSite deletes the association of a contact with a site.
func (*Site) UpdateSite ¶
UpdateSite updates the site information in the DB.
func (*Site) UpdateSiteFirstPing ¶
UpdateSiteFirstPing updates the up/down status and last status change of a Site.