Refactor fluent download pipelines
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
namespace Beam.Fluent;
|
||||
|
||||
public enum FragmentMode {
|
||||
Single,
|
||||
Fragmented
|
||||
}
|
||||
|
||||
public enum Channel {
|
||||
Plain,
|
||||
Stealth,
|
||||
Playwright
|
||||
}
|
||||
|
||||
public enum ContentKind {
|
||||
Html,
|
||||
Binary
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Beam.Abstractions;
|
||||
using Beam.Downloaders;
|
||||
using Beam.Models;
|
||||
using Beam.Playwright;
|
||||
using Beam.Stealth;
|
||||
|
||||
namespace Beam.Fluent;
|
||||
|
||||
public interface IContextStage<RawType, OutType> {
|
||||
IContextStage<RawType, OutType> Configure(Action<DownloadContextBuilder<RawType>> configure);
|
||||
IContextStage<RawType, OutType> WithParallelism(int degree);
|
||||
IContextStage<RawType, OutType> WithTimeout(TimeSpan timeout);
|
||||
IContextStage<RawType, OutType> WithRetryReporter(IProgress<IRetryReport> reporter);
|
||||
IContextStage<RawType, OutType> UseFragments();
|
||||
IContextStage<RawType, OutType> UsePlaywright(PlaywrightAsyncManipulator manipulator);
|
||||
IContextStage<RawType, OutType> UseStealth(StealthAsyncManipulator manipulator, StealthConfig config);
|
||||
DownloadEnumerable<OutType> Build();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
namespace Beam.Fluent;
|
||||
|
||||
public interface IDownloadStage<RawType, OutType> {
|
||||
IDownloadStage<RawType, OutType> SaveToDirectory(string dir);
|
||||
IDownloadStage<RawType, OutType> SaveToFiles(IEnumerable<string> files);
|
||||
IDownloadStage<RawType, OutType> SaveToMemory(ConcurrentBag<OutType> bag);
|
||||
void WaitForDownload();
|
||||
Task WaitForDownloadAsync();
|
||||
DownloadEnumerable<OutType> AsAsyncEnumerable();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Beam.Dynamic;
|
||||
using Beam.Models;
|
||||
|
||||
namespace Beam.Fluent;
|
||||
|
||||
public interface ITransformStage<RawType, OutType> {
|
||||
IContextStage<RawType, OutType> WithTransformer(AsyncTransformer<RawType, OutType> factory);
|
||||
}
|
||||
Reference in New Issue
Block a user