probe

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGRPCChecker

func NewGRPCChecker() *gRPCChecker

NewGRPCChecker creates a new gRPC checker

func RegisterChecker

func RegisterChecker(c Checker)

RegisterChecker registers a checker with the global registry

Types

type AlertDispatcher

type AlertDispatcher interface {
	ProcessJudgment(soul *core.Soul, prevStatus core.SoulStatus, judgment *core.Judgment)
}

AlertDispatcher is the interface for firing alerts

type Checker

type Checker interface {
	// Type returns the protocol identifier
	Type() core.CheckType

	// Judge performs the health check against the given soul
	Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

	// Validate ensures the soul configuration is valid for this checker
	Validate(soul *core.Soul) error
}

Checker is the interface every protocol must implement. Named after the priests who assisted Anubis in the weighing ceremony.

func GetChecker

func GetChecker(t core.CheckType) Checker

GetChecker returns a checker by type from the global registry

type CheckerRegistry

type CheckerRegistry struct {
	// contains filtered or unexported fields
}

CheckerRegistry maps check types to their implementations

func NewCheckerRegistry

func NewCheckerRegistry() *CheckerRegistry

NewCheckerRegistry creates a new registry with all built-in checkers

func (*CheckerRegistry) Get

func (r *CheckerRegistry) Get(t core.CheckType) (Checker, bool)

Get retrieves a checker by type

func (*CheckerRegistry) List

func (r *CheckerRegistry) List() []core.CheckType

List returns all registered checker types

func (*CheckerRegistry) Register

func (r *CheckerRegistry) Register(c Checker)

Register adds a checker to the registry

type CircuitBreakerConfig added in v0.0.2

type CircuitBreakerConfig struct {
	Enabled          bool          // Enable circuit breaker
	FailureThreshold int           // Failures before opening (default: 5)
	SuccessThreshold int           // Successes before closing (default: 3)
	Timeout          time.Duration // Time before attempting again (default: 30s)
}

CircuitBreakerConfig configures circuit breaker behavior

type DNSChecker

type DNSChecker struct{}

DNSChecker implements DNS resolution checks

func NewDNSChecker

func NewDNSChecker() *DNSChecker

NewDNSChecker creates a new DNS checker

func (*DNSChecker) Judge

func (c *DNSChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the DNS check

func (*DNSChecker) Type

func (c *DNSChecker) Type() core.CheckType

Type returns the protocol identifier

func (*DNSChecker) Validate

func (c *DNSChecker) Validate(soul *core.Soul) error

Validate checks configuration

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine is the probe scheduling and execution engine. It manages the lifecycle of all soul checks on this Jackal.

func NewEngine

func NewEngine(opts EngineOptions) *Engine

NewEngine creates a new probe engine

func (*Engine) AssignSouls

func (e *Engine) AssignSouls(souls []*core.Soul)

AssignSouls sets the souls this Jackal is responsible for checking. Called by the Raft leader when distributing checks. Souls with region restrictions are filtered to only run on matching probes.

func (*Engine) Config added in v0.0.2

func (e *Engine) Config() EngineConfig

Config returns the engine configuration

func (*Engine) ForceCheck

func (e *Engine) ForceCheck(soulID string) (*core.Judgment, error)

ForceCheck triggers an immediate check (REST API compatible)

func (*Engine) GetSoulStatus

func (e *Engine) GetSoulStatus(soulID string) (*core.SoulStatus, error)

GetSoulStatus returns the current status of a soul

func (*Engine) GetStatus

func (e *Engine) GetStatus() *core.ProbeStatus

GetStatus returns probe engine status (REST API compatible)

func (*Engine) ListActiveSouls

func (e *Engine) ListActiveSouls() []*core.Soul

ListActiveSouls returns all currently assigned souls

func (*Engine) SetOnJudgment added in v0.1.0

func (e *Engine) SetOnJudgment(fn func(*core.Judgment))

SetOnJudgment sets the callback function for judgment events

func (*Engine) Stats

func (e *Engine) Stats() map[string]interface{}

Stats returns engine statistics

func (*Engine) Stop

func (e *Engine) Stop()

Stop gracefully shuts down the probe engine

func (*Engine) TriggerImmediate

func (e *Engine) TriggerImmediate(ctx context.Context, soulID string) (*core.Judgment, error)

TriggerImmediate forces an immediate check of a specific soul

type EngineConfig added in v0.0.2

type EngineConfig struct {
	MaxConcurrentChecks int // Maximum concurrent checks (default: 100)
	CircuitBreaker      CircuitBreakerConfig
	NodeID              string
	Region              string
}

EngineConfig configures probe engine behavior

func DefaultEngineConfig added in v0.0.2

func DefaultEngineConfig() EngineConfig

DefaultEngineConfig returns default engine configuration

type EngineOptions

type EngineOptions struct {
	Registry   *CheckerRegistry
	Store      Storage
	Alerter    AlertDispatcher
	NodeID     string
	Region     string
	Logger     *slog.Logger
	OnJudgment func(*core.Judgment)
	Config     EngineConfig
}

EngineOptions configures the probe engine

type HTTPChecker

type HTTPChecker struct {
	// contains filtered or unexported fields
}

HTTPChecker implements HTTP/HTTPS health checks

func NewHTTPChecker

func NewHTTPChecker() *HTTPChecker

NewHTTPChecker creates a new HTTP checker

func (*HTTPChecker) Judge

func (c *HTTPChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

func (*HTTPChecker) Type

func (c *HTTPChecker) Type() core.CheckType

Type returns the protocol identifier

func (*HTTPChecker) Validate

func (c *HTTPChecker) Validate(soul *core.Soul) error

Validate checks if the soul configuration is valid

type ICMPChecker

type ICMPChecker struct{}

ICMPChecker implements ICMP ping checks

func NewICMPChecker

func NewICMPChecker() *ICMPChecker

NewICMPChecker creates a new ICMP checker

func (*ICMPChecker) Judge

func (c *ICMPChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the ICMP ping check

func (*ICMPChecker) Type

func (c *ICMPChecker) Type() core.CheckType

Type returns the protocol identifier

func (*ICMPChecker) Validate

func (c *ICMPChecker) Validate(soul *core.Soul) error

Validate checks configuration

type IMAPChecker

type IMAPChecker struct{}

IMAPChecker implements IMAP health checks

func NewIMAPChecker

func NewIMAPChecker() *IMAPChecker

NewIMAPChecker creates a new IMAP checker

func (*IMAPChecker) Judge

func (c *IMAPChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the IMAP check

func (*IMAPChecker) Type

func (c *IMAPChecker) Type() core.CheckType

Type returns the protocol identifier

func (*IMAPChecker) Validate

func (c *IMAPChecker) Validate(soul *core.Soul) error

Validate checks configuration

type SMTPChecker

type SMTPChecker struct{}

SMTPChecker implements SMTP health checks

func NewSMTPChecker

func NewSMTPChecker() *SMTPChecker

NewSMTPChecker creates a new SMTP checker

func (*SMTPChecker) Judge

func (c *SMTPChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the SMTP check

func (*SMTPChecker) Type

func (c *SMTPChecker) Type() core.CheckType

Type returns the protocol identifier

func (*SMTPChecker) Validate

func (c *SMTPChecker) Validate(soul *core.Soul) error

Validate checks configuration

type Storage

type Storage interface {
	SaveJudgment(ctx context.Context, j *core.Judgment) error
	GetSoul(ctx context.Context, workspaceID, soulID string) (*core.Soul, error)
	ListSouls(ctx context.Context, workspaceID string) ([]*core.Soul, error)
}

Storage is the interface the probe engine uses to persist judgments

type TCPChecker

type TCPChecker struct{}

TCPChecker implements TCP health checks

func NewTCPChecker

func NewTCPChecker() *TCPChecker

NewTCPChecker creates a new TCP checker

func (*TCPChecker) Judge

func (c *TCPChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the TCP check

func (*TCPChecker) Type

func (c *TCPChecker) Type() core.CheckType

Type returns the protocol identifier

func (*TCPChecker) Validate

func (c *TCPChecker) Validate(soul *core.Soul) error

Validate checks configuration

type TLSChecker

type TLSChecker struct{}

TLSChecker implements TLS certificate checks

func NewTLSChecker

func NewTLSChecker() *TLSChecker

NewTLSChecker creates a new TLS checker

func (*TLSChecker) Judge

func (c *TLSChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the TLS certificate check

func (*TLSChecker) Type

func (c *TLSChecker) Type() core.CheckType

Type returns the protocol identifier

func (*TLSChecker) Validate

func (c *TLSChecker) Validate(soul *core.Soul) error

Validate checks configuration

type UDPChecker

type UDPChecker struct{}

UDPChecker implements UDP health checks

func NewUDPChecker

func NewUDPChecker() *UDPChecker

NewUDPChecker creates a new UDP checker

func (*UDPChecker) Judge

func (c *UDPChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the UDP check

func (*UDPChecker) Type

func (c *UDPChecker) Type() core.CheckType

Type returns the protocol identifier

func (*UDPChecker) Validate

func (c *UDPChecker) Validate(soul *core.Soul) error

Validate checks configuration

type WebSocketChecker

type WebSocketChecker struct{}

WebSocketChecker implements WebSocket health checks

func NewWebSocketChecker

func NewWebSocketChecker() *WebSocketChecker

NewWebSocketChecker creates a new WebSocket checker

func (*WebSocketChecker) Judge

func (c *WebSocketChecker) Judge(ctx context.Context, soul *core.Soul) (*core.Judgment, error)

Judge performs the WebSocket check

func (*WebSocketChecker) Type

func (c *WebSocketChecker) Type() core.CheckType

Type returns the protocol identifier

func (*WebSocketChecker) Validate

func (c *WebSocketChecker) Validate(soul *core.Soul) error

Validate checks configuration

Jump to

Keyboard shortcuts

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