From 758284f80e6f695df821188971560da04d0f6123 Mon Sep 17 00:00:00 2001 From: Erik Knauf Date: Fri, 8 Feb 2019 15:23:47 +0100 Subject: [PATCH] Set EnableCrossPartitionQuery=true --- Hangfire.AzureDocumentDB/DocumentDbConnection.cs | 11 +++++++++-- Hangfire.AzureDocumentDB/DocumentDbMonitoringApi.cs | 11 +++++++++-- .../Queue/JobQueueMonitoringApi.cs | 10 ++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Hangfire.AzureDocumentDB/DocumentDbConnection.cs b/Hangfire.AzureDocumentDB/DocumentDbConnection.cs index 977d2d7..9a4cf59 100644 --- a/Hangfire.AzureDocumentDB/DocumentDbConnection.cs +++ b/Hangfire.AzureDocumentDB/DocumentDbConnection.cs @@ -214,7 +214,11 @@ public override List GetRangeFromSet(string key, int startingFrom, int e { if (key == null) throw new ArgumentNullException(nameof(key)); - FeedOptions feedOptions = new FeedOptions { MaxItemCount = endingAt + 1 }; + FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, + MaxItemCount = endingAt + 1 + }; + endingAt += 1 - startingFrom; return Storage.Client.CreateDocumentQuery(Storage.CollectionUri, feedOptions) @@ -486,7 +490,10 @@ public override List GetRangeFromList(string key, int startingFrom, int { if (key == null) throw new ArgumentNullException(nameof(key)); - FeedOptions feedOptions = new FeedOptions { MaxItemCount = endingAt + 1 }; + FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, + MaxItemCount = endingAt + 1 + }; endingAt += 1 - startingFrom; return Storage.Client.CreateDocumentQuery(Storage.CollectionUri, feedOptions) diff --git a/Hangfire.AzureDocumentDB/DocumentDbMonitoringApi.cs b/Hangfire.AzureDocumentDB/DocumentDbMonitoringApi.cs index 40ebc2f..18eac9a 100644 --- a/Hangfire.AzureDocumentDB/DocumentDbMonitoringApi.cs +++ b/Hangfire.AzureDocumentDB/DocumentDbMonitoringApi.cs @@ -119,6 +119,7 @@ public StatisticsDto GetStatistics() FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, MaxItemCount = 1000, }; @@ -290,7 +291,10 @@ public JobList DeletedJobs(int from, int count) private JobList GetJobsOnState(string stateName, int from, int count, Func selector) { List> jobs = new List>(); - FeedOptions feedOptions = new FeedOptions { MaxItemCount = from + count }; + FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, + MaxItemCount = from + count + }; List filterJobs = storage.Client.CreateDocumentQuery(storage.CollectionUri, feedOptions) .Where(j => j.DocumentType == DocumentTypes.Job && j.StateName == stateName) @@ -334,7 +338,10 @@ private JobList GetJobsOnQueue(string queryText, string queue, int from, i } }; - FeedOptions feedOptions = new FeedOptions { MaxItemCount = from + count }; + FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, + MaxItemCount = from + count + }; List queues = storage.Client.CreateDocumentQuery(storage.CollectionUri, sql, feedOptions) .ToQueryResult() diff --git a/Hangfire.AzureDocumentDB/Queue/JobQueueMonitoringApi.cs b/Hangfire.AzureDocumentDB/Queue/JobQueueMonitoringApi.cs index 4784953..baf7655 100644 --- a/Hangfire.AzureDocumentDB/Queue/JobQueueMonitoringApi.cs +++ b/Hangfire.AzureDocumentDB/Queue/JobQueueMonitoringApi.cs @@ -65,7 +65,10 @@ public int GetEnqueuedCount(string queue) public IEnumerable GetEnqueuedJobIds(string queue, int from, int perPage) { - FeedOptions feedOptions = new FeedOptions { MaxItemCount = from + perPage }; + FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, + MaxItemCount = from + perPage + }; return storage.Client.CreateDocumentQuery(storage.CollectionUri, feedOptions) .Where(q => q.DocumentType == DocumentTypes.Queue && q.Name == queue && q.FetchedAt.IsDefined() == false) @@ -77,7 +80,10 @@ public IEnumerable GetEnqueuedJobIds(string queue, int from, int perPage public IEnumerable GetFetchedJobIds(string queue, int from, int perPage) { - FeedOptions feedOptions = new FeedOptions { MaxItemCount = from + perPage }; + FeedOptions feedOptions = new FeedOptions { + EnableCrossPartitionQuery = true, + MaxItemCount = from + perPage + }; return storage.Client.CreateDocumentQuery(storage.CollectionUri, feedOptions) .Where(q => q.DocumentType == DocumentTypes.Queue && q.Name == queue && q.FetchedAt.IsDefined())