Skip to content

Commit 44ffcf4

Browse files
Gadam8adam.gloyne
andauthored
feat(bindings): add high throughput fifo properties (LEGO#135)
Co-authored-by: adam.gloyne <[email protected]>
1 parent f923c65 commit 44ffcf4

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@ namespace LEGO.AsyncAPI.Bindings.Sqs
22
{
33
using System;
44
using System.Collections.Generic;
5-
using LEGO.AsyncAPI.Models;
65
using LEGO.AsyncAPI.Models.Interfaces;
76
using LEGO.AsyncAPI.Writers;
8-
using Extensions;
9-
using LEGO.AsyncAPI.Readers;
10-
using LEGO.AsyncAPI.Readers.ParseNodes;
7+
using LEGO.AsyncAPI.Attributes;
118

129
public class Queue : IAsyncApiExtensible
1310
{
@@ -21,6 +18,16 @@ public class Queue : IAsyncApiExtensible
2118
/// </summary>
2219
public bool FifoQueue { get; set; }
2320

21+
/// <summary>
22+
/// Specifies whether message deduplication occurs at the message group or queue level. Valid values are messageGroup and queue (default).
23+
/// </summary>
24+
public DeduplicationScope? DeduplicationScope { get; set; }
25+
26+
/// <summary>
27+
/// Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group. Valid values are perQueue (default) and perMessageGroupId.
28+
/// </summary>
29+
public FifoThroughputLimit? FifoThroughputLimit { get; set; }
30+
2431
/// <summary>
2532
/// The number of seconds to delay before a message sent to the queue can be received. used to create a delay queue.
2633
/// </summary>
@@ -68,6 +75,8 @@ public void Serialize(IAsyncApiWriter writer)
6875
writer.WriteStartObject();
6976
writer.WriteRequiredProperty("name", this.Name);
7077
writer.WriteOptionalProperty("fifoQueue", this.FifoQueue);
78+
writer.WriteOptionalProperty("deduplicationScope", this.DeduplicationScope?.GetDisplayName());
79+
writer.WriteOptionalProperty("fifoThroughputLimit", this.FifoThroughputLimit?.GetDisplayName());
7180
writer.WriteOptionalProperty("deliveryDelay", this.DeliveryDelay);
7281
writer.WriteOptionalProperty("visibilityTimeout", this.VisibilityTimeout);
7382
writer.WriteOptionalProperty("receiveMessageWaitTime", this.ReceiveMessageWaitTime);
@@ -79,4 +88,16 @@ public void Serialize(IAsyncApiWriter writer)
7988
writer.WriteEndObject();
8089
}
8190
}
91+
92+
public enum DeduplicationScope
93+
{
94+
[Display("queue")] Queue,
95+
[Display("messageGroup")] MessageGroup,
96+
}
97+
98+
public enum FifoThroughputLimit
99+
{
100+
[Display("perQueue")] PerQueue,
101+
[Display("perMessageGroupId")] PerMessageGroupId,
102+
}
82103
}

src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class SqsChannelBinding : ChannelBinding<SqsChannelBinding>
3131
{
3232
{ "name", (a, n) => { a.Name = n.GetScalarValue(); } },
3333
{ "fifoQueue", (a, n) => { a.FifoQueue = n.GetBooleanValue(); } },
34+
{ "deduplicationScope", (a, n) => { a.DeduplicationScope = n.GetScalarValue().GetEnumFromDisplayName<DeduplicationScope>(); } },
35+
{ "fifoThroughputLimit", (a, n) => { a.FifoThroughputLimit = n.GetScalarValue().GetEnumFromDisplayName<FifoThroughputLimit>(); } },
3436
{ "deliveryDelay", (a, n) => { a.DeliveryDelay = n.GetIntegerValue(); } },
3537
{ "visibilityTimeout", (a, n) => { a.VisibilityTimeout = n.GetIntegerValue(); } },
3638
{ "receiveMessageWaitTime", (a, n) => { a.ReceiveMessageWaitTime = n.GetIntegerValue(); } },

src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public class SqsOperationBinding : OperationBinding<SqsOperationBinding>
2323
{
2424
{ "name", (a, n) => { a.Name = n.GetScalarValue(); } },
2525
{ "fifoQueue", (a, n) => { a.FifoQueue = n.GetBooleanValue(); } },
26+
{ "deduplicationScope", (a, n) => { a.DeduplicationScope = n.GetScalarValue().GetEnumFromDisplayName<DeduplicationScope>(); } },
27+
{ "fifoThroughputLimit", (a, n) => { a.FifoThroughputLimit = n.GetScalarValue().GetEnumFromDisplayName<FifoThroughputLimit>(); } },
2628
{ "deliveryDelay", (a, n) => { a.DeliveryDelay = n.GetIntegerValue(); } },
2729
{ "visibilityTimeout", (a, n) => { a.VisibilityTimeout = n.GetIntegerValue(); } },
2830
{ "receiveMessageWaitTime", (a, n) => { a.ReceiveMessageWaitTime = n.GetIntegerValue(); } },

test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes()
2323
queue:
2424
name: myQueue
2525
fifoQueue: true
26+
deduplicationScope: messageGroup
27+
fifoThroughputLimit: perMessageGroupId
2628
deliveryDelay: 30
2729
visibilityTimeout: 60
2830
receiveMessageWaitTime: 0
@@ -78,6 +80,8 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes()
7880
{
7981
Name = "myQueue",
8082
FifoQueue = true,
83+
DeduplicationScope = DeduplicationScope.MessageGroup,
84+
FifoThroughputLimit = FifoThroughputLimit.PerMessageGroupId,
8185
DeliveryDelay = 30,
8286
VisibilityTimeout = 60,
8387
ReceiveMessageWaitTime = 0,
@@ -233,7 +237,6 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes()
233237
sqs:
234238
queues:
235239
- name: myQueue
236-
fifoQueue: true
237240
deliveryDelay: 30
238241
visibilityTimeout: 60
239242
receiveMessageWaitTime: 0
@@ -291,7 +294,9 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes()
291294
new Queue()
292295
{
293296
Name = "myQueue",
294-
FifoQueue = true,
297+
FifoQueue = false,
298+
DeduplicationScope = null,
299+
FifoThroughputLimit = null,
295300
DeliveryDelay = 30,
296301
VisibilityTimeout = 60,
297302
ReceiveMessageWaitTime = 0,

0 commit comments

Comments
 (0)