From 2ef2b73a7ebc0fe4fbcc3b19743ab5afc4e7353a Mon Sep 17 00:00:00 2001 From: "adam.gloyne" Date: Thu, 26 Oct 2023 16:00:01 +0100 Subject: [PATCH 1/2] Add high throughput fifo properties --- src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs | 29 ++++++++++++++++--- .../Sqs/SqsChannelBinding.cs | 2 ++ .../Sqs/SqsOperationBinding.cs | 2 ++ .../Bindings/Sqs/SqsBindings_should.cs | 8 +++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs index f79e0ad3..4eec17ef 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs @@ -2,12 +2,9 @@ namespace LEGO.AsyncAPI.Bindings.Sqs { using System; using System.Collections.Generic; - using LEGO.AsyncAPI.Models; using LEGO.AsyncAPI.Models.Interfaces; using LEGO.AsyncAPI.Writers; - using Extensions; - using LEGO.AsyncAPI.Readers; - using LEGO.AsyncAPI.Readers.ParseNodes; + using LEGO.AsyncAPI.Attributes; public class Queue : IAsyncApiExtensible { @@ -21,6 +18,16 @@ public class Queue : IAsyncApiExtensible /// public bool FifoQueue { get; set; } + /// + /// Specifies whether message deduplication occurs at the message group or queue level. Valid values are messageGroup and queue (default). + /// + public DeduplicationScope? DeduplicationScope { get; set; } + + /// + /// Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group. Valid values are perQueue (default) and perMessageGroupId. + /// + public FifoThroughputLimit? FifoThroughputLimit { get; set; } + /// /// The number of seconds to delay before a message sent to the queue can be received. used to create a delay queue. /// @@ -68,6 +75,8 @@ public void Serialize(IAsyncApiWriter writer) writer.WriteStartObject(); writer.WriteRequiredProperty("name", this.Name); writer.WriteOptionalProperty("fifoQueue", this.FifoQueue); + writer.WriteOptionalProperty("deduplicationScope", this.DeduplicationScope?.GetDisplayName()); + writer.WriteOptionalProperty("fifoThroughputLimit", this.FifoThroughputLimit?.GetDisplayName()); writer.WriteOptionalProperty("deliveryDelay", this.DeliveryDelay); writer.WriteOptionalProperty("visibilityTimeout", this.VisibilityTimeout); writer.WriteOptionalProperty("receiveMessageWaitTime", this.ReceiveMessageWaitTime); @@ -79,4 +88,16 @@ public void Serialize(IAsyncApiWriter writer) writer.WriteEndObject(); } } + + public enum DeduplicationScope + { + [Display("queue")] Queue, + [Display("messageGroup")] MessageGroup, + } + + public enum FifoThroughputLimit + { + [Display("perQueue")] PerQueue, + [Display("perMessageGroupId")] PerMessageGroupId, + } } \ No newline at end of file diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs index 2142b105..b64bed31 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs @@ -31,6 +31,8 @@ public class SqsChannelBinding : ChannelBinding { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, { "fifoQueue", (a, n) => { a.FifoQueue = n.GetBooleanValue(); } }, + { "deduplicationScope", (a, n) => { a.DeduplicationScope = n.GetScalarValue().GetEnumFromDisplayName(); } }, + { "fifoThroughputLimit", (a, n) => { a.FifoThroughputLimit = n.GetScalarValue().GetEnumFromDisplayName(); } }, { "deliveryDelay", (a, n) => { a.DeliveryDelay = n.GetIntegerValue(); } }, { "visibilityTimeout", (a, n) => { a.VisibilityTimeout = n.GetIntegerValue(); } }, { "receiveMessageWaitTime", (a, n) => { a.ReceiveMessageWaitTime = n.GetIntegerValue(); } }, diff --git a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs index 9aff5a90..de2372f1 100644 --- a/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs +++ b/src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs @@ -23,6 +23,8 @@ public class SqsOperationBinding : OperationBinding { { "name", (a, n) => { a.Name = n.GetScalarValue(); } }, { "fifoQueue", (a, n) => { a.FifoQueue = n.GetBooleanValue(); } }, + { "deduplicationScope", (a, n) => { a.DeduplicationScope = n.GetScalarValue().GetEnumFromDisplayName(); } }, + { "fifoThroughputLimit", (a, n) => { a.FifoThroughputLimit = n.GetScalarValue().GetEnumFromDisplayName(); } }, { "deliveryDelay", (a, n) => { a.DeliveryDelay = n.GetIntegerValue(); } }, { "visibilityTimeout", (a, n) => { a.VisibilityTimeout = n.GetIntegerValue(); } }, { "receiveMessageWaitTime", (a, n) => { a.ReceiveMessageWaitTime = n.GetIntegerValue(); } }, diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs index 34c361e1..62365b0e 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs @@ -23,6 +23,8 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() queue: name: myQueue fifoQueue: true + deduplicationScope: messageGroup + fifoThroughputLimit: perMessageGroupId deliveryDelay: 30 visibilityTimeout: 60 receiveMessageWaitTime: 0 @@ -78,6 +80,8 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes() { Name = "myQueue", FifoQueue = true, + DeduplicationScope = DeduplicationScope.MessageGroup, + FifoThroughputLimit = FifoThroughputLimit.PerMessageGroupId, DeliveryDelay = 30, VisibilityTimeout = 60, ReceiveMessageWaitTime = 0, @@ -234,6 +238,8 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() queues: - name: myQueue fifoQueue: true + deduplicationScope: queue + fifoThroughputLimit: perQueue deliveryDelay: 30 visibilityTimeout: 60 receiveMessageWaitTime: 0 @@ -292,6 +298,8 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() { Name = "myQueue", FifoQueue = true, + DeduplicationScope = DeduplicationScope.Queue, + FifoThroughputLimit = FifoThroughputLimit.PerQueue, DeliveryDelay = 30, VisibilityTimeout = 60, ReceiveMessageWaitTime = 0, From 0846aa504401fd425be4cda1032b13b55461dcf3 Mon Sep 17 00:00:00 2001 From: "adam.gloyne" Date: Mon, 30 Oct 2023 11:08:24 +0000 Subject: [PATCH 2/2] Test when no fifo input --- .../Bindings/Sqs/SqsBindings_should.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs b/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs index 62365b0e..3ce6fb72 100644 --- a/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs +++ b/test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs @@ -237,9 +237,6 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() sqs: queues: - name: myQueue - fifoQueue: true - deduplicationScope: queue - fifoThroughputLimit: perQueue deliveryDelay: 30 visibilityTimeout: 60 receiveMessageWaitTime: 0 @@ -297,9 +294,9 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() new Queue() { Name = "myQueue", - FifoQueue = true, - DeduplicationScope = DeduplicationScope.Queue, - FifoThroughputLimit = FifoThroughputLimit.PerQueue, + FifoQueue = false, + DeduplicationScope = null, + FifoThroughputLimit = null, DeliveryDelay = 30, VisibilityTimeout = 60, ReceiveMessageWaitTime = 0,