Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add QueueConfiguration.JsonSerializerSettings #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions osu.Server.QueueProcessor/QueueConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Newtonsoft.Json;

namespace osu.Server.QueueProcessor
{
public class QueueConfiguration
Expand Down Expand Up @@ -34,5 +36,10 @@ public class QueueConfiguration
/// Setting above 1 will allow processing in batches (see <see cref="QueueProcessor{T}.ProcessResults"/>).
/// </summary>
public int BatchSize { get; set; } = 1;

/// <summary>
/// Serialization settings to use when deserializing items from redis.
/// </summary>
public JsonSerializerSettings? JsonSerializerSettings { get; set; } = null;
}
}
2 changes: 1 addition & 1 deletion osu.Server.QueueProcessor/QueueProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void Run(CancellationToken cancellation = default)

// null or empty check is required for redis 6.x. 7.x reports `null` instead.
foreach (var redisItem in redisItems.Where(i => !i.IsNullOrEmpty))
items.Add(JsonConvert.DeserializeObject<T>(redisItem) ?? throw new InvalidOperationException("Dequeued item could not be deserialised."));
items.Add(JsonConvert.DeserializeObject<T>(redisItem, config.JsonSerializerSettings) ?? throw new InvalidOperationException("Dequeued item could not be deserialised."));

if (items.Count == 0)
{
Expand Down