-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathApp.ts
39 lines (33 loc) · 932 Bytes
/
App.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import {AddToQueue, FromQueue, Job, JobOverride, Launcher, logger, OnStart} from "ppspider";
class TestTask {
@OnStart({
urls: "onStart"
})
@AddToQueue({
name: "test"
})
async onStart() {
logger.debug("add jobs to test queue");
return ["job_1", "job_2", "job_2#1", "job_3", "job_3#2"];
}
@JobOverride("test")
overrideJobInfo(job: Job, parentJob: Job) {
// job_2#1 和 job_3#2 两个任务的key将改为 job_2,job_3,然后被 BloonFilter 过滤掉
job.key = job.url.split("#")[0];
job.datas.referer = parentJob.url;
}
@FromQueue({
name: "test"
})
async fromQueue(job: Job) {
logger.debug("fetch job from test queue and execute: " + job.url + ", referer: " + job.datas.referer);
}
}
@Launcher({
workplace: "workplace",
tasks: [
TestTask
],
workerFactorys: []
})
class App {}