Skip to content

Commit 3acf710

Browse files
committed
♻️ 配置项 threads 重命名为 concurrency
1 parent fc73c3e commit 3acf710

9 files changed

Lines changed: 18 additions & 18 deletions

File tree

bundle/config.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ search-limit = 30
2727
search-filter = 1
2828

2929
[crawl]
30-
# 并发数 (默认值:100)
31-
threads =
30+
# 并发上限 (默认值:100)
31+
concurrency =
3232
# 最小间隔 (毫秒)
3333
min-interval = 200
3434
# 最大间隔 (毫秒)

bundle/rules/flowlimit-rules.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"nextPage": "#wrapper > article > div.bottem1 > a:nth-child(3)"
3939
},
4040
"crawl": {
41-
"threads": 5,
41+
"concurrency": 5,
4242
"minInterval": 1000,
4343
"maxInterval": 2000
4444
}
@@ -86,7 +86,7 @@
8686
"nextChapterLink": "https://www\\.0xs\\.net/txt/\\d+/\\d+\\.html"
8787
},
8888
"crawl": {
89-
"threads": 1,
89+
"concurrency": 1,
9090
"minInterval": 1000,
9191
"maxInterval": 3000
9292
}
@@ -130,7 +130,7 @@
130130
"filterTag": ""
131131
},
132132
"crawl": {
133-
"threads": 1,
133+
"concurrency": 1,
134134
"minInterval": 1000,
135135
"maxInterval": 2000
136136
}
@@ -175,7 +175,7 @@
175175
"nextPage": ".prenext > span:nth-child(3) > a"
176176
},
177177
"crawl": {
178-
"threads": 1,
178+
"concurrency": 1,
179179
"minInterval": 1000,
180180
"maxInterval": 2000
181181
}

bundle/rules/proxy-rules.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"filterTag": "h1 div"
3131
},
3232
"crawl": {
33-
"threads": 1,
33+
"concurrency": 1,
3434
"minInterval": 1000,
3535
"maxInterval": 2000
3636
}

bundle/rules/rule-template.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@
9595
},
9696
// 限流书源必填
9797
"crawl": {
98-
// 线程数
99-
"threads": 0,
98+
// 并发数
99+
"concurrency": 0,
100100
// 最小间隔(单位:秒)
101101
"minInterval": 0,
102102
// 最大间隔(单位:秒)

src/main/java/com/pcdd/sonovel/core/AppConfigLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public AppConfig loadConfig() {
8080
cfg.setSearchFilter(usr.getInt("search-filter", SELECTION_SOURCE, 1));
8181

8282
// [crawl]
83-
cfg.setThreads(usr.getInt("threads", SELECTION_CRAWL, -1));
83+
cfg.setConcurrency(usr.getInt("concurrency", SELECTION_CRAWL, -1));
8484
cfg.setMinInterval(usr.getInt("min-interval", SELECTION_CRAWL, 200));
8585
cfg.setMaxInterval(usr.getInt("max-interval", SELECTION_CRAWL, 400));
8686
cfg.setEnableRetry(usr.getInt("enable-retry", SELECTION_CRAWL, 1));

src/main/java/com/pcdd/sonovel/core/Crawler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ public double crawl(String bookUrl, List<Chapter> toc) {
8282
return 0;
8383
}
8484

85-
int autoThreads = config.getThreads() == -1
85+
int autoThreads = config.getConcurrency() == -1
8686
// IO 密集型任务,不要和 CPU 核数绑定
8787
? Math.min(100, toc.size())
88-
: config.getThreads();
88+
: config.getConcurrency();
8989

9090
Console.log("<== 开始下载《{}》({}) 共计 {} 章 | 最大并发:{}",
9191
book.getBookName(), book.getAuthor(), toc.size(), autoThreads);

src/main/java/com/pcdd/sonovel/core/Source.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public Source(Rule rule, AppConfig config) {
3232
Rule.Crawl crawl = rule.getCrawl();
3333
if (crawl != null) {
3434
if (crawl.getThreads() != null) {
35-
this.config.setThreads(crawl.getThreads());
35+
this.config.setConcurrency(crawl.getThreads());
3636
}
3737
if (crawl.getMinInterval() != null) {
3838
this.config.setMinInterval(crawl.getMinInterval());

src/main/java/com/pcdd/sonovel/model/AppConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class AppConfig {
2929
private Integer searchFilter;
3030

3131
// [crawl]
32-
private Integer threads;
32+
private Integer concurrency;
3333
private Integer minInterval;
3434
private Integer maxInterval;
3535
private Integer enableRetry;

src/test/resources/rule/broken-rules.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"filterTag": "div"
115115
},
116116
"crawl": {
117-
"threads": 1,
117+
"concurrency": 1,
118118
"min": 1000,
119119
"max": 2000,
120120
"maxAttempts": 5,
@@ -151,7 +151,7 @@
151151
"filterTag": "h1 div br"
152152
},
153153
"crawl": {
154-
"threads": 1,
154+
"concurrency": 1,
155155
"min": 1000,
156156
"max": 2000,
157157
"maxAttempts": 5,
@@ -187,7 +187,7 @@
187187
"filterTag": "div br"
188188
},
189189
"crawl": {
190-
"threads": 1,
190+
"concurrency": 1,
191191
"min": 1000,
192192
"max": 2000,
193193
"maxAttempts": 5,
@@ -315,7 +315,7 @@
315315
"nextPage": ".prenext > span:nth-child(3) > a"
316316
},
317317
"crawl": {
318-
"threads": 1,
318+
"concurrency": 1,
319319
"minInterval": 1000,
320320
"maxInterval": 2000
321321
}

0 commit comments

Comments
 (0)