Skip to content

Commit

Permalink
feat(bindings): add high throughput fifo properties (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: adam.gloyne <[email protected]>
  • Loading branch information
Gadam8 and adam.gloyne authored Nov 1, 2023
1 parent f923c65 commit 44ffcf4
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
29 changes: 25 additions & 4 deletions src/LEGO.AsyncAPI.Bindings/Sqs/Queue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -21,6 +18,16 @@ public class Queue : IAsyncApiExtensible
/// </summary>
public bool FifoQueue { get; set; }

/// <summary>
/// Specifies whether message deduplication occurs at the message group or queue level. Valid values are messageGroup and queue (default).
/// </summary>
public DeduplicationScope? DeduplicationScope { get; set; }

/// <summary>
/// Specifies whether the FIFO queue throughput quota applies to the entire queue or per message group. Valid values are perQueue (default) and perMessageGroupId.
/// </summary>
public FifoThroughputLimit? FifoThroughputLimit { get; set; }

/// <summary>
/// The number of seconds to delay before a message sent to the queue can be received. used to create a delay queue.
/// </summary>
Expand Down Expand Up @@ -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);
Expand All @@ -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,
}
}
2 changes: 2 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sqs/SqsChannelBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class SqsChannelBinding : ChannelBinding<SqsChannelBinding>
{
{ "name", (a, n) => { a.Name = n.GetScalarValue(); } },
{ "fifoQueue", (a, n) => { a.FifoQueue = n.GetBooleanValue(); } },
{ "deduplicationScope", (a, n) => { a.DeduplicationScope = n.GetScalarValue().GetEnumFromDisplayName<DeduplicationScope>(); } },
{ "fifoThroughputLimit", (a, n) => { a.FifoThroughputLimit = n.GetScalarValue().GetEnumFromDisplayName<FifoThroughputLimit>(); } },
{ "deliveryDelay", (a, n) => { a.DeliveryDelay = n.GetIntegerValue(); } },
{ "visibilityTimeout", (a, n) => { a.VisibilityTimeout = n.GetIntegerValue(); } },
{ "receiveMessageWaitTime", (a, n) => { a.ReceiveMessageWaitTime = n.GetIntegerValue(); } },
Expand Down
2 changes: 2 additions & 0 deletions src/LEGO.AsyncAPI.Bindings/Sqs/SqsOperationBinding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public class SqsOperationBinding : OperationBinding<SqsOperationBinding>
{
{ "name", (a, n) => { a.Name = n.GetScalarValue(); } },
{ "fifoQueue", (a, n) => { a.FifoQueue = n.GetBooleanValue(); } },
{ "deduplicationScope", (a, n) => { a.DeduplicationScope = n.GetScalarValue().GetEnumFromDisplayName<DeduplicationScope>(); } },
{ "fifoThroughputLimit", (a, n) => { a.FifoThroughputLimit = n.GetScalarValue().GetEnumFromDisplayName<FifoThroughputLimit>(); } },
{ "deliveryDelay", (a, n) => { a.DeliveryDelay = n.GetIntegerValue(); } },
{ "visibilityTimeout", (a, n) => { a.VisibilityTimeout = n.GetIntegerValue(); } },
{ "receiveMessageWaitTime", (a, n) => { a.ReceiveMessageWaitTime = n.GetIntegerValue(); } },
Expand Down
9 changes: 7 additions & 2 deletions test/LEGO.AsyncAPI.Tests/Bindings/Sqs/SqsBindings_should.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public void SqsChannelBinding_WithFilledObject_SerializesAndDeserializes()
queue:
name: myQueue
fifoQueue: true
deduplicationScope: messageGroup
fifoThroughputLimit: perMessageGroupId
deliveryDelay: 30
visibilityTimeout: 60
receiveMessageWaitTime: 0
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -233,7 +237,6 @@ public void SqsOperationBinding_WithFilledObject_SerializesAndDeserializes()
sqs:
queues:
- name: myQueue
fifoQueue: true
deliveryDelay: 30
visibilityTimeout: 60
receiveMessageWaitTime: 0
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 44ffcf4

Please sign in to comment.