-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
67 additions
and
35 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
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,30 @@ | ||
namespace Firecrawl; | ||
|
||
public partial class CrawlClient | ||
{ | ||
/// <summary> | ||
/// Waits for a crawl job to complete or fail. | ||
/// </summary> | ||
/// <param name="jobId"></param> | ||
/// <param name="cancellationToken">The token to cancel the operation with</param> | ||
/// <exception cref="global::System.InvalidOperationException"></exception> | ||
public async Task<GetCrawlStatusResponse> WaitJobAsync( | ||
string jobId, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
while (true) | ||
{ | ||
cancellationToken.ThrowIfCancellationRequested(); | ||
|
||
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false); | ||
|
||
var statusResponse = await GetCrawlStatusAsync( | ||
jobId: jobId, | ||
cancellationToken: cancellationToken).ConfigureAwait(false); | ||
if (statusResponse.Status is "completed" or "failed") | ||
{ | ||
return statusResponse; | ||
} | ||
} | ||
} | ||
} |
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