Help us shape the future of Go! Take the 2026 Go Developer Survey

monitor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	URL       string     `json:"url"`
	Type      ChangeType `json:"type"`
	Field     string     `json:"field,omitempty"`
	OldValue  string     `json:"old_value,omitempty"`
	NewValue  string     `json:"new_value,omitempty"`
	Timestamp time.Time  `json:"timestamp"`
}

Change represents a detected content change.

type ChangeDetector

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

ChangeDetector compares crawl results against historical snapshots.

func NewChangeDetector

func NewChangeDetector(snapshotDir string, logger *slog.Logger) *ChangeDetector

NewChangeDetector creates a new change detector.

func (*ChangeDetector) Detect

func (cd *ChangeDetector) Detect(item *types.Item) ([]Change, error)

Detect compares an item against its last snapshot and returns changes.

type ChangeType

type ChangeType string

ChangeType identifies what kind of change occurred.

const (
	ChangeAdded    ChangeType = "added"
	ChangeModified ChangeType = "modified"
	ChangeRemoved  ChangeType = "removed"
)

type DiffResult

type DiffResult struct {
	URL     string   `json:"url"`
	Added   []string `json:"added,omitempty"`
	Removed []string `json:"removed,omitempty"`
	Changed []string `json:"changed,omitempty"`
}

DiffResult holds the result of a content diff.

func DiffText

func DiffText(old, new string) DiffResult

DiffText computes a line-level diff between two text strings.

type NotificationChannel

type NotificationChannel interface {
	Send(ctx context.Context, changes []Change) error
	Type() NotificationType
}

NotificationChannel is an interface for notification delivery.

type NotificationType

type NotificationType string

NotificationType specifies the notification channel.

const (
	NotifyWebhook NotificationType = "webhook"
	NotifySlack   NotificationType = "slack"
	NotifyEmail   NotificationType = "email"
)

type Notifier

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

Notifier sends notifications when changes are detected.

func NewNotifier

func NewNotifier(logger *slog.Logger) *Notifier

NewNotifier creates a new change notifier.

func (*Notifier) AddChannel

func (n *Notifier) AddChannel(ch NotificationChannel)

AddChannel registers a notification channel.

func (*Notifier) Notify

func (n *Notifier) Notify(ctx context.Context, changes []Change)

Notify sends changes to all registered channels.

type Schedule

type Schedule struct {
	Name     string        `json:"name"`
	URLs     []string      `json:"urls"`
	Interval time.Duration `json:"interval"`
	MaxDepth int           `json:"max_depth"`
	Rules    []string      `json:"rules,omitempty"`
}

Schedule represents a recurring crawl schedule.

type Scheduler

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

Scheduler runs crawls on a schedule.

func NewScheduler

func NewScheduler(logger *slog.Logger) *Scheduler

NewScheduler creates a new crawl scheduler.

func (*Scheduler) Add

func (s *Scheduler) Add(sched *Schedule)

Add adds a schedule.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context, crawlFunc func(urls []string, depth int) error)

Start begins executing schedules.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler.

type WebhookChannel

type WebhookChannel struct {
	URL string
	// contains filtered or unexported fields
}

WebhookChannel sends notifications via HTTP webhook.

func (*WebhookChannel) Send

func (w *WebhookChannel) Send(ctx context.Context, changes []Change) error

func (*WebhookChannel) Type

func (w *WebhookChannel) Type() NotificationType

Jump to

Keyboard shortcuts

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