Documentation ¶
Overview ¶
Package scheme implements how to probe or send alert to the URL.
All scheme structs implement Prober and/or Alerter.
Index ¶
- Constants
- Variables
- func SplitScheme(scheme string) (subScheme string, separator rune, variant string)
- type AlertReporter
- type Alerter
- type AlerterSet
- type DNSProbe
- type DummyScheme
- type ExecScheme
- type FTPScheme
- type FileScheme
- type FixedSourceReporter
- type HTTPScheme
- type PingProbe
- type PluginScheme
- type Prober
- type Reporter
- type SourceScheme
- type TCPProbe
- type TargetTracker
- func (t *TargetTracker) Activate(target *api.URL)
- func (t *TargetTracker) DeactivateTarget(_ *api.URL, _ ...*api.URL)
- func (t *TargetTracker) Inactives() []*api.URL
- func (t *TargetTracker) PrepareReporter(source *api.URL, r Reporter) Reporter
- func (t *TargetTracker) Report(_ *api.URL, rec api.Record)
Constants ¶
const (
HTTP_REDIRECT_MAX = 10
)
Variables ¶
var ( ErrInvalidAlertURL = errors.New("invalid alert URL") ErrUnsupportedAlertScheme = errors.New("unsupported scheme for alert") )
var ( ErrUnsupportedDNSType = errors.New("unsupported DNS type") ErrConflictDNSType = errors.New("DNS type in scheme and query is conflicted") ErrMissingDomainName = errors.New("missing domain name") )
var ( ErrMissingUsername = errors.New("username is required if set password") ErrMissingPassword = errors.New("password is required if set username") )
var ( ErrInvalidURL = errors.New("invalid URL") ErrMissingScheme = errors.New("missing scheme in URL") ErrUnsupportedScheme = errors.New("unsupported scheme") ErrMissingHost = errors.New("missing target host") )
var ( ErrInvalidSource = errors.New("invalid source") ErrInvalidSourceURL = errors.New("invalid source URL") ErrMissingFile = errors.New("missing file") )
var (
ErrFailedToPreparePing = errors.New("failed to setup ping service")
)
var (
ErrMissingCommand = errors.New("missing command")
)
var (
ErrRedirectLoopDetected = errors.New("redirect loop detected")
)
var (
ErrTCPPortMissing = errors.New("TCP target's port number is required")
)
var (
HTTPUserAgent = "ayd health check"
)
Functions ¶
Types ¶
type AlertReporter ¶
AlertReporter is a wrapper of Reporter interface for alert schemes. It replaces source URL, and puts "alert:" prefix to the target URL.
func (AlertReporter) DeactivateTarget ¶
func (r AlertReporter) DeactivateTarget(source *api.URL, targets ...*api.URL)
type Alerter ¶
type Alerter interface { // Target returns the alert target URL. // This URL should not change during lifetime of the instance. Target() *api.URL // Alert sends an alert to the target, and report result(s) to the Reporter. Alert(context.Context, Reporter, api.Record) }
Alerter is the interface to send alerts to somewhere.
func NewAlerter ¶
type AlerterSet ¶
type AlerterSet []Alerter
AlerterSet is a set of alerts. It also implements Alerter alertinterface.
func NewAlerterSet ¶
func NewAlerterSet(targets []string) (AlerterSet, error)
func (AlerterSet) Alert ¶
Alert of AlerterSet calls all Alert methods of children parallelly. This method blocks until all alerts done.
func (AlerterSet) Target ¶
func (as AlerterSet) Target() *api.URL
Target implements Alert interface. This method always returns alert-set: URL.
type DNSProbe ¶ added in v0.13.0
type DNSProbe struct {
// contains filtered or unexported fields
}
DNSProbe is a Prober implementation for the DNS protocol.
func NewDNSProbe ¶ added in v0.13.0
NewDNSProbe creates a new DNSProbe.
type DummyScheme ¶
type DummyScheme struct {
// contains filtered or unexported fields
}
func NewDummyScheme ¶
func NewDummyScheme(u *api.URL) (DummyScheme, error)
func (DummyScheme) Status ¶
func (s DummyScheme) Status() api.Status
func (DummyScheme) Target ¶
func (s DummyScheme) Target() *api.URL
type ExecScheme ¶
type ExecScheme struct {
// contains filtered or unexported fields
}
func NewExecScheme ¶
func NewExecScheme(u *api.URL) (ExecScheme, error)
func (ExecScheme) Target ¶
func (s ExecScheme) Target() *api.URL
type FTPScheme ¶ added in v0.16.0
type FTPScheme struct {
// contains filtered or unexported fields
}
FTPScheme is a probe/alert implementation for the FTP.
type FileScheme ¶ added in v0.15.0
type FileScheme struct {
// contains filtered or unexported fields
}
FileScheme is a probe/alert implementation for local file.
func NewFileScheme ¶ added in v0.15.0
func NewFileScheme(u *api.URL) (FileScheme, error)
func (FileScheme) Probe ¶ added in v0.15.0
func (s FileScheme) Probe(ctx context.Context, r Reporter)
func (FileScheme) Target ¶ added in v0.15.0
func (s FileScheme) Target() *api.URL
type FixedSourceReporter ¶
FixedSourceReporter is a Reporter that overrides source argument.
This struct is used by TargetTracker.
func (FixedSourceReporter) DeactivateTarget ¶
func (r FixedSourceReporter) DeactivateTarget(source *api.URL, targets ...*api.URL)
DeactivateTarget implements Reporter.
type HTTPScheme ¶
type HTTPScheme struct {
// contains filtered or unexported fields
}
func NewHTTPScheme ¶
func NewHTTPScheme(u *api.URL) (HTTPScheme, error)
func (HTTPScheme) Target ¶
func (s HTTPScheme) Target() *api.URL
type PingProbe ¶ added in v0.13.0
type PingProbe struct {
// contains filtered or unexported fields
}
PingProbe is a Prober implementation for SNMP echo request aka ping.
type PluginScheme ¶
type PluginScheme struct {
// contains filtered or unexported fields
}
PluginScheme is the plugin handler. This implements both of Prober interface and Alerter interface.
func NewPluginAlert ¶
func NewPluginAlert(u *api.URL) (PluginScheme, error)
func NewPluginProbe ¶
func NewPluginProbe(u *api.URL) (PluginScheme, error)
func NewPluginScheme ¶
func NewPluginScheme(u *api.URL, scope string) (PluginScheme, error)
func (PluginScheme) Target ¶
func (p PluginScheme) Target() *api.URL
type Prober ¶
type Prober interface { // Target returns the target URL. // This URL should not change during lifetime of the instance. Target() *api.URL // Probe checks the target is dead or alive, and report result(s) to the Reporter. Probe(context.Context, Reporter) }
Prober is the interface to check the target is dead or alive.
type SourceScheme ¶
type SourceScheme struct {
// contains filtered or unexported fields
}
SourceScheme implements how to load target URLs from file, HTTP, or external command.
func NewSourceAlert ¶
func NewSourceAlert(u *api.URL) (SourceScheme, error)
NewSourceAlert makes a new SourceScheme instance. It checks each URLs in source as an Alerter.
func NewSourceProbe ¶
func NewSourceProbe(u *api.URL) (SourceScheme, error)
NewSourceProbe makes a new SourceScheme instance. It checks each URLs in source as a Prober.
func (SourceScheme) Target ¶
func (p SourceScheme) Target() *api.URL
type TCPProbe ¶ added in v0.13.0
type TCPProbe struct {
// contains filtered or unexported fields
}
TCPProbe is a Prober implementation for the TCP.
type TargetTracker ¶
TargetTracker tracks the targets is active or not.
func (*TargetTracker) Activate ¶
func (t *TargetTracker) Activate(target *api.URL)
Activate removes target URL from inactive list and appends to active list.
func (*TargetTracker) DeactivateTarget ¶
func (t *TargetTracker) DeactivateTarget(_ *api.URL, _ ...*api.URL)
DeactivateTarget implements Reporter. it does nothing.
func (*TargetTracker) Inactives ¶
func (t *TargetTracker) Inactives() []*api.URL
Inactives returns the list of inactive targets that not reported since last PrepareReporter called.
func (*TargetTracker) PrepareReporter ¶
func (t *TargetTracker) PrepareReporter(source *api.URL, r Reporter) Reporter
PrepareReporter prepares to tracking a new probe with a new reporter.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package textdecode is a utility package to decode text.
|
Package textdecode is a utility package to decode text. |