| 123456789101112131415161718192021222324252627 |
- using Admin.NET.Plugin.AiDOP.DataPlatform.Core;
- namespace Admin.NET.Plugin.AiDOP.DataPlatform.UnifiedIngress;
- /// <summary>Bridges the host's authenticated source binding to the independent ingress contract.</summary>
- public sealed class MdpIngestContractBinder(MdpIngestDatasetRegistry datasets) : ITransient
- {
- private static readonly PurchaseOrderSchemaRegistry BuiltIn = new();
- public async Task<PreparedIngestBatch> PrepareAsync(
- long tenantId, long factoryId, long sourceId, string datasetKey, ReadOnlyMemory<byte> payload, IngestLimits limits, long? configurationFactoryId = null)
- {
- var binding = await datasets.ResolveActiveBindingAsync(tenantId, configurationFactoryId ?? factoryId, sourceId, datasetKey)
- ?? throw new IngestContractException(IngestContractError.DatasetUnavailable);
- var identity = new IngestDatasetIdentity(binding.TenantId, factoryId, binding.SourceId,
- binding.DatasetId, binding.SourceCode, binding.DatasetKey);
- ISchemaRegistry registry = BuiltIn;
- if (BuiltIn.Find(binding.DatasetKey, binding.SourceSchemaVersion) == null)
- {
- var json = await datasets.ReadPublishedMapping(binding)
- ?? throw new IngestContractException(IngestContractError.UnknownSchema);
- registry = new PurchaseVersionConfiguration(binding.DatasetKey, binding.SourceSchemaVersion, json);
- }
- return new IngestBatchPreparer(registry).Prepare(identity, binding.SourceSchemaVersion, payload.Span, limits);
- }
- }
|