| | | 1 | | using AsiBackbone.Core.Audit; |
| | | 2 | | using AsiBackbone.Core.CapabilityTokens; |
| | | 3 | | using AsiBackbone.Core.Outbox; |
| | | 4 | | using AsiBackbone.DependencyInjection; |
| | | 5 | | using AsiBackbone.Storage.InMemory.Audit; |
| | | 6 | | using AsiBackbone.Storage.InMemory.CapabilityTokens; |
| | | 7 | | using AsiBackbone.Storage.InMemory.Outbox; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection; |
| | | 9 | | |
| | | 10 | | namespace AsiBackbone.Storage.InMemory; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Provides explicit builder facade extension methods for non-durable in-memory storage. |
| | | 14 | | /// </summary> |
| | | 15 | | public static class InMemoryStorageBuilderExtensions |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// Adds the non-durable in-memory audit sink through the AsiBackbone builder facade. |
| | | 19 | | /// </summary> |
| | | 20 | | public static IAsiBackboneBuilder UseInMemoryAuditLedger(this IAsiBackboneBuilder builder) |
| | | 21 | | { |
| | 4 | 22 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 23 | | |
| | 2 | 24 | | _ = builder.Services.AddSingleton<InMemoryAuditLedger>(); |
| | 2 | 25 | | _ = builder.Services.AddSingleton<IAsiBackboneAuditSink>(serviceProvider => |
| | 4 | 26 | | serviceProvider.GetRequiredService<InMemoryAuditLedger>()); |
| | | 27 | | |
| | 2 | 28 | | return builder; |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Adds the non-durable in-memory audit residue lifecycle store through the AsiBackbone builder facade. |
| | | 33 | | /// </summary> |
| | | 34 | | public static IAsiBackboneBuilder UseInMemoryAuditLifecycle(this IAsiBackboneBuilder builder) |
| | | 35 | | { |
| | 4 | 36 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 37 | | |
| | 2 | 38 | | _ = builder.Services.AddSingleton<IAsiBackboneAuditResidueLifecycleStore, InMemoryAuditResidueLifecycleStore>(); |
| | 2 | 39 | | return builder; |
| | | 40 | | } |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Adds the non-durable in-memory governance outbox store through the AsiBackbone builder facade. |
| | | 44 | | /// </summary> |
| | | 45 | | public static IAsiBackboneBuilder UseInMemoryGovernanceOutbox(this IAsiBackboneBuilder builder) |
| | | 46 | | { |
| | 4 | 47 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 48 | | |
| | 2 | 49 | | _ = builder.Services.AddSingleton<IAsiBackboneGovernanceOutboxStore, InMemoryGovernanceOutboxStore>(); |
| | 2 | 50 | | return builder; |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// Adds the non-durable in-memory capability grant use store through the AsiBackbone builder facade. |
| | | 55 | | /// </summary> |
| | | 56 | | public static IAsiBackboneBuilder UseInMemoryCapabilityGrantUseStore(this IAsiBackboneBuilder builder) |
| | | 57 | | { |
| | 6 | 58 | | ArgumentNullException.ThrowIfNull(builder); |
| | | 59 | | |
| | 4 | 60 | | _ = builder.Services.AddSingleton<InMemoryCapabilityGrantUseStore>(); |
| | 4 | 61 | | _ = builder.Services.AddSingleton<ICapabilityGrantUseStore>(serviceProvider => |
| | 8 | 62 | | serviceProvider.GetRequiredService<InMemoryCapabilityGrantUseStore>()); |
| | | 63 | | |
| | 4 | 64 | | return builder; |
| | | 65 | | } |
| | | 66 | | } |