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

Commit

Permalink
Merge pull request #35 from erikpaperik/bugfix/enable-cross-aprtition…
Browse files Browse the repository at this point in the history
…-query

Set EnableCrossPartitionQuery=true
  • Loading branch information
imranmomin authored Feb 11, 2019
2 parents 6825038 + 758284f commit f7f6fc0
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 f7f6fc0

Please sign in to comment.