From 44ffcf4ceaf06a5168597e1eeb9407f09d47ab23 Mon Sep 17 00:00:00 2001 From: Gadam8 <44494964+Gadam8@users.noreply.github.com> Date: Wed, 1 Nov 2023 13:25:14 +0000 Subject: [PATCH] feat(bindings): add high throughput fifo properties (#135) Co-authored-by: adam.gloyne --- src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs | 29 ++++++++++++++++--- .../Sqs/SqsChannelBinding.cs | 2 ++ .../Sqs/SqsOperationBinding.cs | 2 ++ .../Bindings/Sqs/SqsBindings_should.cs | 9 ++++-- 4 files changed, 36 insertions(+), 6 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..3ce6fb72 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, @@ -233,7 +237,6 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() sqs: queues: - name: myQueue - fifoQueue: true deliveryDelay: 30 visibilityTimeout: 60 receiveMessageWaitTime: 0 @@ -291,7 +294,9 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes() new Queue() { Name = "myQueue", - FifoQueue = true, + FifoQueue = false, + DeduplicationScope = null, + FifoThroughputLimit = null, DeliveryDelay = 30, VisibilityTimeout = 60, ReceiveMessageWaitTime = 0,