-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
+ interfaces
ICrawler
, ICrawlFacade
, IPostParser
& IPostSaver
- generic type param `TBaseRevision` @ CrawlFacade.cs @ c#/crawler
- Loading branch information
Showing
12 changed files
with
75 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace tbm.Crawler.Tieba.Crawl.Crawler; | ||
|
||
public interface ICrawler<in TResponse, out TPostProtoBuf> | ||
where TResponse : class, IMessage<TResponse> | ||
where TPostProtoBuf : class, IMessage<TPostProtoBuf> | ||
{ | ||
public Exception FillExceptionData(Exception e); | ||
public IReadOnlyCollection<TPostProtoBuf> GetValidPosts(TResponse response, CrawlRequestFlag flag); | ||
public TbClient.Page? GetResponsePage(TResponse response); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace tbm.Crawler.Tieba.Crawl.Facade; | ||
|
||
public interface ICrawlFacade<TPost> : IDisposable | ||
where TPost : BasePost | ||
{ | ||
public SaverChangeSet<TPost>? SaveCrawled(CancellationToken stoppingToken = default); | ||
|
||
public Task<ICrawlFacade<TPost>> CrawlPageRange( | ||
Page startPage, | ||
Page endPage = Page.MaxValue, | ||
CancellationToken stoppingToken = default); | ||
|
||
public Task<SaverChangeSet<TPost>?> RetryThenSave( | ||
IReadOnlyList<Page> pages, | ||
Func<Page, FailureCount> failureCountSelector, | ||
CancellationToken stoppingToken = default); | ||
|
||
public ICrawlFacade<TPost> AddExceptionHandler(ExceptionHandler handler); | ||
|
||
public delegate void ExceptionHandler(Exception ex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace tbm.Crawler.Tieba.Crawl.Parser.Post; | ||
|
||
public interface IPostParser<TPost, in TPostProtoBuf> | ||
where TPost : BasePost | ||
where TPostProtoBuf : class, IMessage<TPostProtoBuf> | ||
{ | ||
public void Parse( | ||
CrawlRequestFlag requestFlag, | ||
IReadOnlyCollection<TPostProtoBuf> inPosts, | ||
out IReadOnlyDictionary<PostId, TPost> outPosts, | ||
out IReadOnlyCollection<TbClient.User> outUsers); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace tbm.Crawler.Tieba.Crawl.Saver.Post; | ||
|
||
public interface IPostSaver<TPost> where TPost : BasePost | ||
{ | ||
public IFieldChangeIgnorance.FieldChangeIgnoranceDelegates UserFieldChangeIgnorance { get; } | ||
public PostType CurrentPostType { get; } | ||
public void OnPostSaveEvent(); | ||
public SaverChangeSet<TPost> Save(CrawlerDbContext db); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters