Skip to content

Commit

Permalink
enhancement: send an event that scraping has started
Browse files Browse the repository at this point in the history
  • Loading branch information
cdxker authored and densumesh committed Nov 21, 2024
1 parent f9e0f5b commit e4f8e14
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/src/bin/crawl-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,19 @@ async fn scrape_worker(
}
}

event_queue
.send(ClickHouseEvent::WorkerEvent(
WorkerEvent::from_details(
crawl_request.dataset_id,
models::EventType::CrawlStarted {
scrape_id: crawl_request.scrape_id,
crawl_options: crawl_request.clone().crawl_options,
},
)
.into(),
))
.await;

match crawl(crawl_request.clone(), pool.clone(), redis_pool.clone()).await {
Ok(scrape_report) => {
log::info!("Scrape job completed: {:?}", scrape_report);
Expand Down
8 changes: 8 additions & 0 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,6 +1781,11 @@ pub enum EventType {
GroupChunksUpdated { group_id: uuid::Uuid },
#[display(fmt = "group_chunks_action_failed")]
GroupChunksActionFailed { group_id: uuid::Uuid, error: String },
#[display(fmt = "crawl_started")]
CrawlStarted {
scrape_id: uuid::Uuid,
crawl_options: CrawlOptions,
},
#[display(fmt = "crawl_completed")]
CrawlCompleted {
scrape_id: uuid::Uuid,
Expand Down Expand Up @@ -1810,6 +1815,7 @@ impl EventType {
EventTypeRequest::GroupChunksUpdated,
EventTypeRequest::GroupChunksActionFailed,
EventTypeRequest::CrawlCompleted,
EventTypeRequest::CrawlStarted,
EventTypeRequest::CrawlFailed,
]
}
Expand Down Expand Up @@ -6003,6 +6009,8 @@ pub enum EventTypeRequest {
CrawlCompleted,
#[display(fmt = "crawl_failed")]
CrawlFailed,
#[display(fmt = "crawl_started")]
CrawlStarted,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
Expand Down

0 comments on commit e4f8e14

Please sign in to comment.