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(); } } } }