/// <inheritdoc /> public EventHubContentLocationEventStore( EventHubContentLocationEventStoreConfiguration configuration, IContentLocationEventHandler eventHandler, string localMachineName, CentralStorage centralStorage, Interfaces.FileSystem.AbsolutePath workingDirectory) : base(configuration, nameof(EventHubContentLocationEventStore), eventHandler, centralStorage, workingDirectory) { Contract.Requires(configuration.MaxEventProcessingConcurrency >= 1); _configuration = configuration; _localMachineName = localMachineName; if (configuration.MaxEventProcessingConcurrency > 1) { _eventProcessingBlocks = Enumerable.Range(1, configuration.MaxEventProcessingConcurrency) .Select( _ => { var serializer = new ContentLocationEventDataSerializer(configuration.SelfCheckSerialization ? ValidationMode.Trace : ValidationMode.Off); return(new ActionBlock <ProcessEventsInput>( t => ProcessEventsCoreAsync(t, serializer), new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 1, BoundedCapacity = configuration.EventProcessingMaxQueueSize, })); }) .ToArray(); } }
/// <inheritdoc /> public MemoryContentLocationEventStore( MemoryContentLocationEventStoreConfiguration configuration, IContentLocationEventHandler handler, CentralStorage centralStorage, Interfaces.FileSystem.AbsolutePath workingDirectory) : base(configuration, nameof(MemoryContentLocationEventStore), handler, centralStorage, workingDirectory) { _hub = configuration.Hub; _hub.OnEvent += HubOnEvent; }
public SlowedEventHubContentLocationEventStore( ContentLocationEventStoreConfiguration configuration, IContentLocationEventHandler eventHandler, string localMachineName, CentralStorage centralStorage, AbsolutePath workingDirectory) : base(configuration, eventHandler, localMachineName, centralStorage, workingDirectory) { Contract.Requires(configuration is SlowedContentLocationEventStoreConfiguration); _configuration = (configuration as SlowedContentLocationEventStoreConfiguration) !; }
private static ContentLocationEventStore CreateEventStore( ContentLocationEventStoreConfiguration configuration, IContentLocationEventHandler eventHandler, string localMachineName, LocalDiskCentralStorage centralStorage, DisposableDirectory eventHubWorkingDirectory) { return(configuration switch { SlowedContentLocationEventStoreConfiguration _ => new SlowedEventHubContentLocationEventStore(configuration, eventHandler, localMachineName, centralStorage, eventHubWorkingDirectory.Path), _ => ContentLocationEventStore.Create(configuration, eventHandler, localMachineName, centralStorage, eventHubWorkingDirectory.Path), });
private async Task WithContentLocationEventStore(Func <Context, IClock, IAbsFileSystem, ContentLocationEventStore, Task> action, ContentLocationEventStoreConfiguration configuration, IContentLocationEventHandler eventHandler, string localMachineName = "Worker") { string centralStateKeyBase = "ThisIsUnused"; var clock = new MemoryClock(); using var fileSystem = new PassThroughFileSystem(TestGlobal.Logger); var tracingContext = new Context(TestGlobal.Logger); { using var localDiskCentralStoreWorkingDirectory = new DisposableDirectory(fileSystem); var localDiskCentralStoreConfiguration = new LocalDiskCentralStoreConfiguration(localDiskCentralStoreWorkingDirectory.Path, centralStateKeyBase); var centralStorage = new LocalDiskCentralStorage(localDiskCentralStoreConfiguration); { using var eventHubWorkingDirectory = new DisposableDirectory(fileSystem); var eventStore = CreateEventStore(configuration, eventHandler, localMachineName, centralStorage, eventHubWorkingDirectory, clock); (await eventStore.StartupAsync(tracingContext)).ShouldBeSuccess(); await action(tracingContext, clock, fileSystem, eventStore); if (!eventStore.ShutdownStarted) { (await eventStore.ShutdownAsync(tracingContext)).ShouldBeSuccess(); } } } }