public IDocumentWriter <TKey, TEntity> GetWriter <TKey, TEntity>() { var bucket = _strategy.GetEntityBucket <TEntity>(); var store = _store.GetOrAdd(bucket, s => new ConcurrentDictionary <string, byte[]>()); return(new MemoryDocumentReaderWriter <TKey, TEntity>(_strategy, store)); }
public void SetUp() { _strategy = new JsonDocumentStrategy(); _store = new FileDocumentStore(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Remove(0, 6), _strategy); _store.Reset(_strategy.GetEntityBucket<TestObject>()); _store.Reset(_strategy.GetEntityBucket<TestEvent>()); _store.Reset(_strategy.GetEntityBucket<TestWrapper>()); }
public void SetUp() { _strategy = new JsonDocumentStrategy(); _log = Console.Out; _store = new FileDocumentStore(Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Remove(0, 6), _strategy, _log); _store.Reset(_strategy.GetEntityBucket <TestObject>()); _store.Reset(_strategy.GetEntityBucket <TestEvent>()); _store.Reset(_strategy.GetEntityBucket <TestWrapper>()); }
public AzureAtomicWriter(CloudBlobClient directory, IDocumentStrategy strategy) { _strategy = strategy; var folderForEntity = strategy.GetEntityBucket <TEntity>(); _container = directory.GetBlobDirectoryReference(folderForEntity); }
public AzureAtomicReader(CloudBlobClient storage, IDocumentStrategy strategy) { _strategy = strategy; var folder = strategy.GetEntityBucket <TEntity>(); _container = storage.GetBlobDirectoryReference(folder); }
public AzureAtomicWriter(CloudBlobClient storageClient, IDocumentStrategy strategy) { this._strategy = strategy; var folder = strategy.GetEntityBucket <TEntity>(); this._containerDirectory = storageClient.GetBlobDirectory(folder); }
public AzureAtomicReader(CloudBlobClient storageClient, IDocumentStrategy strategy) { this._strategy = strategy; var folder = strategy.GetEntityBucket <TEntity>(); this._containerDirectory = storageClient.GetBlobDirectory(folder); this._logger = NetcoLogger.GetLogger(this.GetType()); this._ap = ActionPolicyAsync.From((exception => { var storageException = exception as StorageException; if (storageException == null) { return(false); } switch (storageException.RequestInformation.HttpStatusCode) { case ( int )HttpStatusCode.InternalServerError: case ( int )HttpStatusCode.ServiceUnavailable: return(true); default: return(false); } })).Retry(200, (ex, i) => { this._logger.Log().Trace(ex, "Retrying Azure API GET call: {0}/200", i); var secondsDelay = 0.2 + 0.1 * _random.Next(-1, 1); // randomize wait time Task.Delay(TimeSpan.FromSeconds(secondsDelay)).Wait(); }); }
public FileDocumentReaderWriter(string directoryPath, IDocumentStrategy strategy) { _strategy = strategy; _folder = Path.Combine(directoryPath, strategy.GetEntityBucket <TEntity>()); }
public FileDocumentReaderWriter(string directoryPath, IDocumentStrategy strategy, TextWriter log) { _folder = Path.Combine(directoryPath, strategy.GetEntityBucket <TEntity>());//.Replace('/', Path.DirectorySeparatorChar); _strategy = strategy; _log = log; }