Skip to content

Commit 23326a6

Browse files
committed
调整azure pipeline
1 parent c773361 commit 23326a6

30 files changed

+129
-58
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ steps:
3939

4040
- task: DotNetCoreInstaller@0
4141
inputs:
42-
version: '3.1.102'
42+
version: '5.0.102'
4343

4444
- script: sh runtests.sh
4545
displayName: 'RunTestCases'

src/DotnetSpider.HBase/HBaseStorage.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public static HBaseStorage CreateFromOptions(IConfiguration configuration)
4949
return storage;
5050
}
5151

52+
public override Task InitializeAsync()
53+
{
54+
return Task.CompletedTask;
55+
}
56+
5257
public HBaseStorage(string restServer)
5358
{
5459
var uri = new Uri(restServer);

src/DotnetSpider.Mongo/MongoEntityStorage.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ internal MongoEntityStorage(IMongoClient mongoClient)
5050
_client = mongoClient;
5151
}
5252

53+
public override Task InitializeAsync()
54+
{
55+
return Task.CompletedTask;
56+
}
57+
5358
protected override async Task HandleAsync(DataFlowContext context,
5459
IDictionary<Type, ICollection<dynamic>> entities)
5560
{

src/DotnetSpider.MySql/MySqlEntityStorage.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Data;
22
using System.Linq;
33
using System.Text;
4+
using System.Threading.Tasks;
45
using DotnetSpider.DataFlow;
56
using DotnetSpider.DataFlow.Storage;
67
using Microsoft.Extensions.Configuration;
@@ -38,6 +39,11 @@ public MySqlEntityStorage(StorageMode mode,
3839
{
3940
}
4041

42+
public override Task InitializeAsync()
43+
{
44+
return Task.CompletedTask;
45+
}
46+
4147
/// <summary>
4248
/// 创建数据库连接接口
4349
/// </summary>

src/DotnetSpider.MySql/MySqlFileEntityStorage.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public class MySqlFileEntityStorage : EntityFileStorageBase
4747

4848
public MySqlFileType MySqlFileType { get; set; }
4949

50+
public override Task InitializeAsync()
51+
{
52+
return Task.CompletedTask;
53+
}
54+
5055
/// <summary>
5156
/// 根据配置返回存储器
5257
/// </summary>

src/DotnetSpider.PostgreSql/PostgreSqlEntityStorage.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Data;
33
using System.Linq;
44
using System.Text;
5+
using System.Threading.Tasks;
56
using Dapper;
67
using DotnetSpider.DataFlow;
78
using DotnetSpider.DataFlow.Storage;
@@ -32,6 +33,11 @@ public static IDataFlow CreateFromOptions(IConfiguration configuration)
3233
};
3334
}
3435

36+
public override Task InitializeAsync()
37+
{
38+
return Task.CompletedTask;
39+
}
40+
3541
/// <summary>
3642
/// 创建数据库和表
3743
/// </summary>

src/DotnetSpider.Sample/DotnetSpider.Sample.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@
2525
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2626
</None>
2727
</ItemGroup>
28-
29-
<ItemGroup>
30-
<Folder Include="logs" />
31-
</ItemGroup>
3228
</Project>

src/DotnetSpider.Sample/samples/BaseUsage.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@ public static async Task RunAsync()
3131

3232
class MyDataParser : DataParser
3333
{
34-
public MyDataParser()
35-
{
36-
AddRequiredValidator("cnblogs\\.com");
37-
AddFollowRequestQuerier(Selectors.XPath("."));
38-
}
39-
4034
protected override Task ParseAsync(DataFlowContext context)
4135
{
4236
context.AddData("URL", context.Request.RequestUri);
4337
context.AddData("Title", context.Selectable.XPath(".//title")?.Value);
4438
return Task.CompletedTask;
4539
}
40+
41+
public override Task InitializeAsync()
42+
{
43+
AddRequiredValidator("cnblogs\\.com");
44+
AddFollowRequestQuerier(Selectors.XPath("."));
45+
46+
return Task.CompletedTask;
47+
}
4648
}
4749

4850
public BaseUsageSpider(IOptions<SpiderOptions> options, DependenceServices services,

src/DotnetSpider.Sample/samples/CnblogsSpider.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ protected override SpiderId CreateSpiderId()
5151

5252
protected class MyConsoleStorage : DataFlowBase
5353
{
54+
public override Task InitializeAsync()
55+
{
56+
return Task.CompletedTask;
57+
}
58+
5459
public override Task HandleAsync(DataFlowContext context)
5560
{
5661
if (IsNullOrEmpty(context))
@@ -72,7 +77,7 @@ public override Task HandleAsync(DataFlowContext context)
7277

7378
protected class ListNewsParser : DataParser
7479
{
75-
public ListNewsParser()
80+
public override Task InitializeAsync()
7681
{
7782
// AddRequiredValidator("news\\.cnblogs\\.com/n/page");
7883
AddRequiredValidator((request =>
@@ -83,6 +88,7 @@ public ListNewsParser()
8388
}));
8489
// if you want to collect every pages
8590
// AddFollowRequestQuerier(Selectors.XPath(".//div[@class='pager']"));
91+
return Task.CompletedTask;
8692
}
8793

8894
protected override Task ParseAsync(DataFlowContext context)
@@ -113,9 +119,10 @@ protected override Task ParseAsync(DataFlowContext context)
113119

114120
protected class NewsParser : DataParser
115121
{
116-
public NewsParser()
122+
public override Task InitializeAsync()
117123
{
118124
AddRequiredValidator("news\\.cnblogs\\.com/n/\\d+");
125+
return Task.CompletedTask;
119126
}
120127

121128
protected override Task ParseAsync(DataFlowContext context)

src/DotnetSpider.Sample/samples/DatabaseSpider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public DatabaseSpider(IOptions<SpiderOptions> options, DependenceServices servic
3131
{
3232
}
3333

34-
protected override async Task InitializeAsync(CancellationToken stoppingToken)
34+
protected override async Task InitializeAsync(CancellationToken stoppingToken = default)
3535
{
3636
AddDataFlow(new ListNewsParser());
3737
AddDataFlow(new NewsParser());
@@ -41,7 +41,7 @@ protected override async Task InitializeAsync(CancellationToken stoppingToken)
4141

4242
class MyStorage : DataFlowBase
4343
{
44-
public override async Task InitAsync()
44+
public override async Task InitializeAsync()
4545
{
4646
await using var conn =
4747
new MySqlConnection(

0 commit comments

Comments
 (0)