Documentation ¶
Index ¶
- func CreatePingerLog(logFilePath string, reinitializeLog bool) error
- func GetEmptySitesMock(db *sql.DB) (database.Sites, error)
- func GetLogContent() (string, error)
- func GetSites(db *sql.DB) (database.Sites, error)
- func GetSitesContentMock(db *sql.DB) (database.Sites, error)
- func GetSitesErrorMock(db *sql.DB) (database.Sites, error)
- func GetSitesMock(db *sql.DB) (database.Sites, error)
- func RequestURL(url string, timeout int) (string, int, time.Duration, error)
- func RequestURLBadInternetAccessMock(url string, timeout int) (string, int, time.Duration, error)
- func RequestURLContentMock(url string, timeout int) (string, int, time.Duration, error)
- func RequestURLMock(url string, timeout int) (string, int, time.Duration, error)
- func ResetHitCount()
- type InternetAccessError
- type Pinger
- type SitesGetter
- type URLRequester
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreatePingerLog ¶
CreatePingerLog creates the log file used by Pinger and Notifier
func GetEmptySitesMock ¶
GetEmptySitesMock is a mock of the SQL query to get the sites for pinging In this case the method returns an empty list of sites.
func GetLogContent ¶
GetLogContent reads the results of the log file for verification.
func GetSitesContentMock ¶ added in v1.3.0
GetSitesContentMock is a mock of the SQL query to get the sites for testing content checks.
func GetSitesErrorMock ¶
GetSitesErrorMock is a mock of the SQL query to get the sites for pinging In this case it returns an error when getting the sites.
func GetSitesMock ¶
GetSitesMock is a mock of the SQL query to get the sites for pinging
func RequestURL ¶
RequestURL provides the implementation of the URLRequester type for runtime usage.
func RequestURLBadInternetAccessMock ¶
RequestURLBadInternetAccessMock mocks the condition where the outgoing Internet connection is down.
func RequestURLContentMock ¶ added in v1.3.0
RequestURLContentMock is a mock of the URL requests for checking content.
func RequestURLMock ¶
RequestURLMock is a mock of the URL request that pings the site.
func ResetHitCount ¶ added in v1.3.0
func ResetHitCount()
ResetHitCount sets the hitcount back to 0 for the tests.
Types ¶
type InternetAccessError ¶
type InternetAccessError struct {
// contains filtered or unexported fields
}
InternetAccessError defines errors where the Internet is inaccessible from the server.
func (InternetAccessError) Error ¶
func (e InternetAccessError) Error() string
type Pinger ¶
type Pinger struct { Sites database.Sites DB *sql.DB RequestURL URLRequester SendEmail notifier.EmailSender SendSms notifier.SmsSender // contains filtered or unexported fields }
Pinger does the HTTP pinging of the sites that are retrieved from the DB.
func NewPinger ¶
func NewPinger(db *sql.DB, getSites SitesGetter, requestURL URLRequester, sendEmail notifier.EmailSender, sendSms notifier.SmsSender) *Pinger
NewPinger returns a new Pinger object
func (*Pinger) Stop ¶
func (p *Pinger) Stop()
Stop stops the Pinger service by sending stop to all pingers and waits until all are stopped via the waitgroup.
func (*Pinger) UpdateSiteSettings ¶
UpdateSiteSettings stops the pinger, regets the sites for changes in settings, and restarts the pinger. There could potentially be race conditions if multiple web controllers were trying to update it so a mutex is used to protect it.
type SitesGetter ¶
SitesGetter defines a function to get the sites from DB or mock.