Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Commit

Permalink
Set EnableCrossPartitionQuery=true
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Knauf committed Feb 8, 2019
1 parent 6825038 commit 758284f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
11 changes: 9 additions & 2 deletions Hangfire.AzureDocumentDB/DocumentDbConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@ public override List<string> 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<Set>(Storage.CollectionUri, feedOptions)
Expand Down Expand Up @@ -486,7 +490,10 @@ public override List<string> 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<List>(Storage.CollectionUri, feedOptions)
Expand Down
11 changes: 9 additions & 2 deletions Hangfire.AzureDocumentDB/DocumentDbMonitoringApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ public StatisticsDto GetStatistics()

FeedOptions feedOptions = new FeedOptions
{
EnableCrossPartitionQuery = true,
MaxItemCount = 1000,
};

Expand Down Expand Up @@ -290,7 +291,10 @@ public JobList<DeletedJobDto> DeletedJobs(int from, int count)
private JobList<T> GetJobsOnState<T>(string stateName, int from, int count, Func<State, Common.Job, T> selector)
{
List<KeyValuePair<string, T>> jobs = new List<KeyValuePair<string, T>>();
FeedOptions feedOptions = new FeedOptions { MaxItemCount = from + count };
FeedOptions feedOptions = new FeedOptions {
EnableCrossPartitionQuery = true,
MaxItemCount = from + count
};

List<Documents.Job> filterJobs = storage.Client.CreateDocumentQuery<Documents.Job>(storage.CollectionUri, feedOptions)
.Where(j => j.DocumentType == DocumentTypes.Job && j.StateName == stateName)
Expand Down Expand Up @@ -334,7 +338,10 @@ private JobList<T> GetJobsOnQueue<T>(string queryText, string queue, int from, i
}
};

FeedOptions feedOptions = new FeedOptions { MaxItemCount = from + count };
FeedOptions feedOptions = new FeedOptions {
EnableCrossPartitionQuery = true,
MaxItemCount = from + count
};

List<Documents.Queue> queues = storage.Client.CreateDocumentQuery<Documents.Queue>(storage.CollectionUri, sql, feedOptions)
.ToQueryResult()
Expand Down
10 changes: 8 additions & 2 deletions Hangfire.AzureDocumentDB/Queue/JobQueueMonitoringApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ public int GetEnqueuedCount(string queue)

public IEnumerable<string> 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<Documents.Queue>(storage.CollectionUri, feedOptions)
.Where(q => q.DocumentType == DocumentTypes.Queue && q.Name == queue && q.FetchedAt.IsDefined() == false)
Expand All @@ -77,7 +80,10 @@ public IEnumerable<string> GetEnqueuedJobIds(string queue, int from, int perPage

public IEnumerable<string> 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<Documents.Queue>(storage.CollectionUri, feedOptions)
.Where(q => q.DocumentType == DocumentTypes.Queue && q.Name == queue && q.FetchedAt.IsDefined())
Expand Down

0 comments on commit 758284f

Please sign in to comment.