feat(HNT-2117): add the agent tick enqueue loop - #37
Conversation
9c08d05 to
57f2332
Compare
422b88b to
b81ce44
Compare
|
Ripple notice, no change requested here yet. Once #35 and #19 land, |
The page due-check reads config, not the page entryThe page crawl cadence becomes a single global configuration value, so This supersedes the page half of the ripple notice above. Why: all 3,399 pages in The trade-off: since the scheduler no longer stamps a window onto each job, a job already on the queue will be evaluated against whatever the discovery worker's setting says when it is handled rather than the value in force at enqueue time. Acceptable for a value that is uniform and changes rarely, but a real property being given up rather than an accident. The capability is deferred rather than abandoned. If per-page or per-topic differentiation is wanted later, and the FPS "Zyte Cost Optimization" page does propose slower crawling for evergreen topics and overnight, it can be reintroduced deliberately at that point. |
Goal
HNT-2117
Add the agent's per-tick enqueue loop.
runTickpublishes a discovery job for each page and acrawl-articlejob for each live article whose crawl interval has elapsed since it was last enqueued, and returns the counts for logging.This builds on the redis-state slice for the enqueue markers, the pubsub package for publishing, the crawl Redis key builders, and the crawl domain message types. See docs/ARCHITECTURE.md in #14 for where the tick sits between the publisher list and the crawl queues.
Implementation decisions
runTickreads and writes its ownpage:enqueuedandarticle:enqueuedmarkers, not the worker-writtenpage:fetchandarticle:fetchkeys.validatePublisherListrejects duplicate URLs, so no two list entries contend on the same key either. A distributed lock would add cost with no benefit.enqueuedWithincompares elapsed time againstinterval_minutesusing the value stored in Redis, and the marker's own TTL is unrelated to the interval.source_urlequal to the article URL and a matching refresh windowcorpus_item, a freshcrawl_idper enqueue,source_urlset to the article URL, andrefresh_interval_minutesset to the agent's live-article interval.source_urlis the article itself. The worker dedups againstrefresh_interval_minutes, so matching it to the agent's live-article interval keeps the worker's refresh window aligned with the agent's cadence rather than the worker default.