Zakira.Conduit.Core
0.5.0
dotnet add package Zakira.Conduit.Core --version 0.5.0
NuGet\Install-Package Zakira.Conduit.Core -Version 0.5.0
<PackageReference Include="Zakira.Conduit.Core" Version="0.5.0" />
<PackageVersion Include="Zakira.Conduit.Core" Version="0.5.0" />
<PackageReference Include="Zakira.Conduit.Core" />
paket add Zakira.Conduit.Core --version 0.5.0
#r "nuget: Zakira.Conduit.Core, 0.5.0"
#:package Zakira.Conduit.Core@0.5.0
#addin nuget:?package=Zakira.Conduit.Core&version=0.5.0
#tool nuget:?package=Zakira.Conduit.Core&version=0.5.0
Zakira.Conduit.Core
The library that powers the Zakira.Conduit global tool.
Zakira.Conduit.Core exposes the manifest model, source abstractions, mirror engine, and synchronizer that the CLI tool wraps. Use it directly when you want to embed conduit's "mirror skills from many sources to many local folders" capability inside your own .NET application instead of shelling out to the tool.
Install
dotnet add package Zakira.Conduit.Core
Quickstart
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Zakira.Conduit.DependencyInjection;
using Zakira.Conduit.Manifest;
using Zakira.Conduit.Synchronization;
var services = new ServiceCollection();
services.AddLogging(b => b.AddConsole());
services.AddConduitCore(github => { github.Token = "ghp_..."; }); // optional
await using var provider = services.BuildServiceProvider();
var loader = provider.GetRequiredService<IManifestLoader>();
var synchronizer = provider.GetRequiredService<IConduitSynchronizer>();
var manifestPath = "/path/to/conduit.json";
var manifest = await loader.LoadAsync(manifestPath);
var report = await synchronizer.SyncAsync(manifest, manifestPath, new SyncOptions());
Console.WriteLine(report.Succeeded ? "ok" : "had failures");
What's in the box
| Namespace | Public types |
|---|---|
Zakira.Conduit.Manifest |
ConduitManifest, ConduitEntry, ISource, GitHubSource, LocalDirectorySource, IManifestLoader, IManifestLocator, ManifestValidator, ManifestException |
Zakira.Conduit.Sources |
ISourceFetcher, ISourceFetcherRegistry, FetchedSource, FetchedContent, FetchContext |
Zakira.Conduit.Sources.GitHub |
GitHubSourceFetcher, IGitHubArchiveDownloader, GitHubFetcherOptions, GitHubDownloadException |
Zakira.Conduit.Sources.Local |
LocalDirectorySourceFetcher, LocalSourceNotFoundException |
Zakira.Conduit.Synchronization |
IConduitSynchronizer, SyncOptions, SyncReport, SyncEntryResult, SyncTargetResult |
Zakira.Conduit.Mirroring |
IDirectoryMirror, AtomicDirectoryMirror |
Zakira.Conduit.Paths |
IPathResolver, DefaultPathResolver |
Zakira.Conduit.Hosting |
IEnvironment, SystemEnvironment |
Zakira.Conduit.DependencyInjection |
ConduitCoreServiceCollectionExtensions |
Adding a new source kind
Implement two small types and register them with DI:
public sealed record GitLabSource : ISource
{
public const string TypeDiscriminator = "gitlab";
[JsonPropertyName("project")] public required string Project { get; init; }
[JsonPropertyName("ref")] public string? Ref { get; init; }
[JsonIgnore] public string Kind => TypeDiscriminator;
}
public sealed class GitLabSourceFetcher : ISourceFetcher
{
public string SourceKind => GitLabSource.TypeDiscriminator;
public Task<FetchedSource> FetchAsync(ISource source, FetchContext context, CancellationToken ct = default)
{
// ... download zip, extract to a temp dir, return a FetchedSource ...
}
}
Then register the discriminator on ISource ([JsonDerivedType]) and the fetcher with DI:
services.AddSingleton<ISourceFetcher, GitLabSourceFetcher>();
The synchronizer and mirror are source-agnostic, so no further wiring is needed.
See also
- The CLI tool:
Zakira.Conduit. - The repository, including manifest schema and examples: https://github.com/MoaidHathot/Zakira.Conduit.
License
MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.DependencyInjection (>= 10.0.8)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.FileSystemGlobbing (>= 10.0.8)
- Microsoft.Extensions.Http (>= 10.0.8)
- Microsoft.Extensions.Logging (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.