Refactor fluent download pipelines

This commit is contained in:
qwsdcvghyu89
2025-09-27 15:38:58 +10:00
parent 13c6fbaf5f
commit 94b6c0645c
33 changed files with 518 additions and 451 deletions
+17
View File
@@ -0,0 +1,17 @@
namespace Beam.Fluent;
public enum FragmentMode {
Single,
Fragmented
}
public enum Channel {
Plain,
Stealth,
Playwright
}
public enum ContentKind {
Html,
Binary
}
+18
View File
@@ -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();
}
+12
View File
@@ -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();
}
+8
View File
@@ -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);
}