private BatchAsyncStreamer GetOrAddStreamerForPartitionKeyRange(string partitionKeyRangeId) { if (this.streamersByPartitionKeyRange.TryGetValue(partitionKeyRangeId, out BatchAsyncStreamer streamer)) { return(streamer); } SemaphoreSlim limiter = this.GetOrAddLimiterForPartitionKeyRange(partitionKeyRangeId); BatchAsyncStreamer newStreamer = new BatchAsyncStreamer( this.maxServerRequestOperationCount, this.maxServerRequestBodyLength, this.timerWheel, limiter, this.defaultMaxDegreeOfConcurrency, this.cosmosClientContext.SerializerCore, this.ExecuteAsync, this.ReBatchAsync, this.cosmosClientContext); if (!this.streamersByPartitionKeyRange.TryAdd(partitionKeyRangeId, newStreamer)) { newStreamer.Dispose(); } return(this.streamersByPartitionKeyRange[partitionKeyRangeId]); }
private BatchAsyncStreamer GetOrAddStreamerForPartitionKeyRange(string partitionKeyRangeId) { if (this.streamersByPartitionKeyRange.TryGetValue(partitionKeyRangeId, out BatchAsyncStreamer streamer)) { return(streamer); } BatchAsyncStreamer newStreamer = new BatchAsyncStreamer(this.maxServerRequestOperationCount, this.maxServerRequestBodyLength, this.dispatchTimerInSeconds, this.timerPool, this.cosmosClientContext.CosmosSerializer, this.ExecuteAsync, this.ReBatchAsync); if (!this.streamersByPartitionKeyRange.TryAdd(partitionKeyRangeId, newStreamer)) { newStreamer.Dispose(); } return(this.streamersByPartitionKeyRange[partitionKeyRangeId]); }