domain

package
v0.0.0-...-a1db402 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

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

func (*Checker) Monitor

func (c *Checker) Monitor(ctx context.Context, websites []WebsiteParams, tick time.Duration) error

Monitor periodically checks websites indefinitely

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL