Documentation
¶
Overview ¶
Package runner wires the crawl engine, analyzer registry, and report builder into a single entry point used by both the CLI and the MCP server.
Index ¶
- func BuildRegistry(fetcher crawler.Fetcher, opts RegistryOptions) *analyze.Registry
- func Run(ctx context.Context, cfg config.Config, seed string, runOpts ...RunOption) (*report.Report, error)
- type AnalyzerInfo
- type Control
- type Phase
- type Progress
- type RegistryOptions
- type RunOption
- type SitemapPreview
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRegistry ¶
func BuildRegistry(fetcher crawler.Fetcher, opts RegistryOptions) *analyze.Registry
BuildRegistry constructs the default analyzer registry. The fetcher is used by analyzers that retrieve additional resources (e.g. the sitemap analyzer). opts turns on the opt-in analyzer modes; the zero value leaves every one of them off.
func Run ¶
func Run(ctx context.Context, cfg config.Config, seed string, runOpts ...RunOption) (*report.Report, error)
Run performs a full crawl + analysis for the given config and seed, returning a Report. The seed argument overrides cfg.Seed when non-empty. runOpts add optional behavior (progress reporting, pause control) for callers that need it; the CLI passes none.
Types ¶
type AnalyzerInfo ¶
AnalyzerInfo describes one registered analyzer.
func ListAnalyzers ¶
func ListAnalyzers() []AnalyzerInfo
ListAnalyzers returns metadata for every registered analyzer.
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control pauses and resumes the crawl inside a Run started with WithControl. Run hides the engine, so Control forwards to it while the crawl phase runs. Calls before the crawl phase are queued (a pause made during the sitemap pre-pass takes effect when crawling starts); calls after it ends do nothing and return false.
Lock order: Control.mu is taken before the engine's locks (Pause and Resume emit a progress event while it is held). Nothing on the progress path takes Control.mu. Active takes no Control lock, but through Engine.ActiveTime it briefly takes the engine's ps.mu and then the activeClock's mutex, one after the other. A caller may therefore call Active while holding its own job lock (that adds a job lock → ps.mu edge, noted in the Engine lock order), but must not call Pause or Resume while holding a lock its progress callback takes.
func (*Control) Active ¶
Active reports the crawl's active time (pauses excluded): 0 before the crawl phase, live during it, frozen after it. Safe to call while holding any lock.
type Progress ¶
type Progress struct {
crawler.Progress
Phase Phase `json:"phase"`
// SitemapFound is true when the pre-pass parsed a sitemap. SitemapTotal counts its
// in-scope URLs; SitemapFetched counts the distinct ones fetched so far.
SitemapFound bool `json:"sitemap_found"`
SitemapTotal int `json:"sitemap_total"`
SitemapFetched int `json:"sitemap_fetched"`
// OffSitemap is Fetched - SitemapFetched: fetched pages the sitemap doesn't list.
OffSitemap int `json:"off_sitemap"`
// InSitemap reports whether CurrentURL (or where it redirected) is in the sitemap.
InSitemap bool `json:"in_sitemap"`
}
Progress is crawler.Progress plus the run phase and progress against the site's sitemap.
func (Progress) TapeOffChar ¶
TapeOffChar is the tape_off character for the page this event reports. The web server builds the live tape_off with it; Run builds Coverage.TapeOff with the same rule.
type RegistryOptions ¶ added in v0.5.0
type RegistryOptions struct {
// Specialized enables the lower-confidence AI-search heuristics (AEO direct-answer-lead,
// GEO quotable-density), the WordPress analyzer's active endpoint probes, and the Shopify
// analyzer's /products.json probe.
Specialized bool
// SecurityAudit enables the security analyzer's TLS, certificate, and cookie audit.
SecurityAudit bool
// IgnoreExternalTagging suppresses the utm analyzer's tagging-quality warnings for
// links leaving the crawled domain. Unlike the other fields it is on by default in
// config (analyzers.ignore_external_tagging); the struct's zero value turns it off.
IgnoreExternalTagging bool
// SitemapOptions configure the sitemap analyzer. runner.Run passes sitemap.WithURLs here
// so the analyzer reuses the pre-pass's sitemap instead of fetching it again.
SitemapOptions []sitemap.Option
}
RegistryOptions turns on the analyzer modes that are off by default. Each corresponds to a config flag under `analyzers`; they are grouped here so adding one doesn't grow BuildRegistry's parameter list into a row of anonymous booleans.
type RunOption ¶
type RunOption func(*runSettings)
RunOption customizes one Run call. The CLI and MCP server call Run without any; the web server uses options for what only it needs (live progress, pause and resume), so Run's signature stays the same for every caller.
func WithControl ¶
WithControl lets the caller pause and resume this Run's crawl through c.
func WithPauseOnThrottle ¶
func WithPauseOnThrottle() RunOption
WithPauseOnThrottle makes the crawl pause itself after sustained 429/503 responses (see crawler.Options.PauseOnThrottle). Only for callers that can resume it, like the web UI.
func WithProgress ¶
WithProgress makes Run report progress to fn: one call per phase change, one per page the crawl records, and one per pause or resume, serialized and in order. fn runs on crawl goroutines (or, for a pause or resume, on the goroutine that asked for it) while the engine holds its locks, so it must return quickly and must not call a Control method.
type SitemapPreview ¶
type SitemapPreview struct {
Found bool `json:"found"`
Total int `json:"total"` // in-scope sitemap URLs
Sources []string `json:"sources"` // sitemap files that parsed, sorted; never null
ViaRobots bool `json:"via_robots"`
}
SitemapPreview is what the sitemap pre-pass would find for a crawl, without crawling.
func PreviewSitemap ¶
PreviewSitemap runs only the sitemap discovery step for cfg and seed: the same robots.txt handling, User-Agent, rate limit and scope rules a crawl would apply. Errors are config errors (bad regex, bad seed); a missing sitemap is Found == false.