This repository was archived by the owner on Aug 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateQueueOptions.cs
More file actions
66 lines (55 loc) · 1.97 KB
/
CreateQueueOptions.cs
File metadata and controls
66 lines (55 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
using TaskFlux.Network.Commands;
namespace TaskFlux.Transport.Tcp.Client;
public class CreateQueueOptions
{
internal (long, long)? PriorityRange { get; set; }
internal int? MaxQueueSize { get; set; }
internal int? MaxMessageSize { get; set; }
internal int ImplementationCode { get; set; } = NetworkPriorityQueueCodes.Heap;
public CreateQueueOptions UseHeap()
{
ImplementationCode = NetworkPriorityQueueCodes.Heap;
return this;
}
public CreateQueueOptions UseQueueArray(long min, long max)
{
CheckPriorityRange(min, max);
PriorityRange = (min, max);
ImplementationCode = NetworkPriorityQueueCodes.QueueArray;
return this;
}
private static void CheckPriorityRange(long min, long max)
{
if (max < min)
{
throw new ArgumentOutOfRangeException(nameof(max), (min, max),
"Минимальный ключ не должен быть больше максимального");
}
}
public CreateQueueOptions WithMaxQueueSize(int maxQueueSize)
{
if (maxQueueSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(maxQueueSize), maxQueueSize,
"Максимальный размер очереди не может быть отрицательным");
}
MaxQueueSize = maxQueueSize;
return this;
}
public CreateQueueOptions WithMaxMessageSize(int maxMessageSize)
{
if (maxMessageSize < 0)
{
throw new ArgumentOutOfRangeException(nameof(maxMessageSize), maxMessageSize,
"Максимальный размер сообщения не может быть отрицательным");
}
MaxMessageSize = maxMessageSize;
return this;
}
public CreateQueueOptions WithPriorityRange(long min, long max)
{
CheckPriorityRange(min, max);
PriorityRange = (min, max);
return this;
}
}