Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct { FetchWebsiteResult func(ctx context.Context, wp WebsiteParams) (*WebsiteResult, error) ProduceResult func(wp WebsiteParams, wr WebsiteResult) error }
Checker is in charge of checks website availability
type HTTPMethod ¶
type HTTPMethod string
HTTPMethod defines the valid HTTP methods to use in the checker
const ( HTTPMethodGet HTTPMethod = http.MethodGet HTTPMethodHead HTTPMethod = http.MethodHead )
func NewHTTPMethod ¶
func NewHTTPMethod(in string) (HTTPMethod, error)
NewHTTPMethod creates a new HTTPMethod based on a string
type WebsiteParams ¶
type WebsiteParams struct { ID string `json:"id"` URL url.URL `json:"-"` Method HTTPMethod `json:"method"` MatchRegexp *regexp.Regexp `json:"-"` }
WebsiteParams defines the website parameters to check against
func NewWebsiteParams ¶
func NewWebsiteParams(rawURL, rawMethod, rawRegexp string) (*WebsiteParams, error)
NewWebsiteParams creates a new WebsiteParmams parsing input strings. An empty rawMethod will set Get HTTP method. An empty rawRegexp will not generate any regular expression.
func (*WebsiteParams) MarshalJSON ¶
func (wp *WebsiteParams) MarshalJSON() ([]byte, error)
MarshalJSON provides custom JSON marshalling.
type WebsiteResult ¶
type WebsiteResult struct { Elapsed time.Duration `json:"elapsed"` Status *int `json:"status"` // Matched optionally says if the body response matched the regular expression if provided. Matched *bool `json:"matched"` // Unreachable means the website check timed out. Unreachable bool `json:"unreachable"` // At determines when the result was recorded At time.Time `json:"at"` }
WebsiteResult defines the result of a website check
Click to show internal directories.
Click to hide internal directories.