Earl.Crawler.Persistence 0.0.0-alpha.0.84

This is a prerelease version of Earl.Crawler.Persistence.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Earl.Crawler.Persistence --version 0.0.0-alpha.0.84                
NuGet\Install-Package Earl.Crawler.Persistence -Version 0.0.0-alpha.0.84                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Earl.Crawler.Persistence" Version="0.0.0-alpha.0.84" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Earl.Crawler.Persistence --version 0.0.0-alpha.0.84                
#r "nuget: Earl.Crawler.Persistence, 0.0.0-alpha.0.84"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Earl.Crawler.Persistence as a Cake Addin
#addin nuget:?package=Earl.Crawler.Persistence&version=0.0.0-alpha.0.84&prerelease

// Install Earl.Crawler.Persistence as a Cake Tool
#tool nuget:?package=Earl.Crawler.Persistence&version=0.0.0-alpha.0.84&prerelease                

Earl Persistence Layer

The "Earl Persistence Layer" refers to a suite of APIs that enable the results of a crawl to be persisted to a backing storage mechanism.

Out-of-the-box, and by design, Earl does not collect the results of a crawl. Rather, Earl provides an Events API that leaves it up to the consumer of the IEarlCrawler contract to handle the CrawlUrlResultEvent in order to consume CrawlUrlResults.

At the lowest level of the Crawler API, this is done by specifying an ICrawlerEvents implementation for the CrawlerOptions.Events provided to the IEarlCrawler. However, more commonly used, is likely the On<TEvent>(this ICrawlerOptionsBuilder builder, CrawlerEventHandler<TEvent> handler) extension method:

var options = CrawlerOptionsBuilder.CreateDefault()
    .On<CrawlUrlResultEvent>(
        async ( CrawlUrlResultEvent e, CancellationToken cancellation ) =>
        {
            // handle the event...
        }
    )
    .Build();

await crawler.CrawlAsync( new Uri(...), options );

The Earl Persistence Layer provides an API around such an event handler in order to ease with saving the results of a crawl. The entry point of the Persistence API is the PersistTo(this ICrawlerOptionsBuilder builder, Action<ICrawlerPersistenceOptionsBuilder> configure) extension method. This extension method exposes an ICrawlerPersistenceOptionsBuilder, which serves as an extension point for persistence implementations to offer a fluent syntax for configuration of the backing storage mechanism.

For example, the JSON Persistence API provides the ToJson(this ICrawlerPersistenceOptionsBuilder builder, Action<ICrawlerJsonPersistenceOptionsBuilder> configure) extension method to configure the persistence of crawl results to JSON files:

var options = CrawlerOptionsBuilder.CreateDefault()
    .PersistTo(
        persist => persist.ToJson( json => json.Destination(...) )
    )
    .Build();

await crawler.CrawlAsync( new Uri(...), options );

Behind the Scenes

The "Persistence Layer" can be described by the following Types, respectively defined in Earl.Crawler.Persistence.Abstractions:

When the CrawlUrlResultEvent is emitted, the ICrawlerPersistenceInvoker is resolved from the event's service provider and invoked to persist the result. The default invoker, CrawlerPersistenceInvoker, uses the ICrawlerPersistenceFactory to create ICrawlerPersistence instances for each of the CrawlerPersistenceOptions.Descriptors passed to the invoker. The default factory implementation, CrawlerPersistenceFactory, resolves a CrawlerPersistenceFactory<TDescriptor> implementation from the current service provider for the type of ICrawlerPersistenceDescriptor passed to the factory. The typed factory is in turn used to create an instance of ICrawlerPersistence to persist the result.

See PersistTo(this ICrawlerOptionsBuilder builder, Action<ICrawlerPersistenceOptionsBuilder> configure).

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Earl.Crawler.Persistence:

Package Downloads
Earl.Crawler.Persistence.Json

An implementation of Earl's "Persistence" pattern for persiting results to JSON files.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.0-alpha.0.111 151 3/30/2022
0.0.0-alpha.0.110 124 3/30/2022
0.0.0-alpha.0.109 124 3/30/2022
0.0.0-alpha.0.108 129 3/30/2022
0.0.0-alpha.0.107 126 3/30/2022
0.0.0-alpha.0.106 123 3/30/2022
0.0.0-alpha.0.104 126 3/29/2022
0.0.0-alpha.0.103 134 3/27/2022
0.0.0-alpha.0.102 132 3/27/2022
0.0.0-alpha.0.101 134 3/27/2022
0.0.0-alpha.0.100 123 3/26/2022
0.0.0-alpha.0.99 138 3/26/2022
0.0.0-alpha.0.98 129 3/25/2022
0.0.0-alpha.0.97 134 3/25/2022
0.0.0-alpha.0.96 133 3/25/2022
0.0.0-alpha.0.95 132 3/25/2022
0.0.0-alpha.0.94 127 3/25/2022
0.0.0-alpha.0.93 123 3/25/2022
0.0.0-alpha.0.92 123 3/24/2022
0.0.0-alpha.0.91 123 3/24/2022
0.0.0-alpha.0.90 122 3/24/2022
0.0.0-alpha.0.89 125 3/24/2022
0.0.0-alpha.0.88 118 3/23/2022
0.0.0-alpha.0.85 125 3/23/2022
0.0.0-alpha.0.84 119 3/23/2022
0.0.0-alpha.0.83 125 3/23/2022
0.0.0-alpha.0.82 121 3/23/2022
0.0.0-alpha.0.79 132 3/22/2022
0.0.0-alpha.0.78 124 3/22/2022
0.0.0-alpha.0.77 132 3/22/2022
0.0.0-alpha.0.76 131 3/22/2022
0.0.0-alpha.0.74 117 3/22/2022
0.0.0-alpha.0.73 130 3/22/2022
0.0.0-alpha.0.72 130 3/21/2022
0.0.0-alpha.0.71 121 3/21/2022
0.0.0-alpha.0.70 131 3/20/2022
0.0.0-alpha.0.69 136 3/19/2022
0.0.0-alpha.0.67 130 3/19/2022
0.0.0-alpha.0.66 133 3/19/2022
0.0.0-alpha.0.65 133 3/19/2022
0.0.0-alpha.0.62 128 3/19/2022
0.0.0-alpha.0.61 127 3/13/2022
0.0.0-alpha.0.60 132 3/13/2022
0.0.0-alpha.0.59 133 3/11/2022
0.0.0-alpha.0.58 135 3/7/2022
0.0.0-alpha.0.57 125 3/7/2022
0.0.0-alpha.0.56 120 3/7/2022
0.0.0-alpha.0.55 125 3/7/2022
0.0.0-alpha.0.54 120 3/7/2022
0.0.0-alpha.0.53 129 3/6/2022
0.0.0-alpha.0.52 128 3/6/2022
0.0.0-alpha.0.51 120 3/6/2022