Skip to content

Commit

Permalink
feat: allow creation of fifo queues
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquedalvi committed Oct 19, 2021
1 parent b0331b5 commit ea5818c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ex_aws_configurator/queue.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule ExAwsConfigurator.QueueAttributes do
@type t :: ExAws.SQS.queue_attributes()

defstruct delay_seconds: 0,
fifo_queue: false,
maximum_message_size: 262_144,
message_retention_period: 1_209_600,
receive_message_wait_time_seconds: 0,
Expand Down
1 change: 1 addition & 0 deletions lib/ex_aws_configurator/sqs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ defmodule ExAwsConfigurator.SQS do
\n\n Creating queue #{full_name} on #{queue.region}
Attributes:
#{IO.ANSI.green()}>#{IO.ANSI.reset()} delay_seconds: #{queue.attributes.delay_seconds}
#{IO.ANSI.green()}>#{IO.ANSI.reset()} fifo_queue: #{queue.attributes.fifo_queue}
#{IO.ANSI.green()}>#{IO.ANSI.reset()} maximum_message_size: #{
queue.attributes.maximum_message_size
}
Expand Down
7 changes: 7 additions & 0 deletions test/ex_aws_configurator/sqs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ defmodule ExAwsConfigurator.SQSTest do
add_queue_to_config(%{queue_min_config: %{}})
add_topic_to_config(build(:topic_config, name: :topic_name))
add_queue_to_config(build(:queue_config, name: :raw_queue, raw_message_delivery: true))
add_queue_to_config(build(:queue_config, name: :fifo_queue, fifo_queue: true))

add_queue_to_config(
build(:queue_config, name: :without_failures_queue, dead_letter_queue: false)
Expand All @@ -21,6 +22,7 @@ defmodule ExAwsConfigurator.SQSTest do
SQS.create_queue(:queue_name)
SNS.create_topic(:topic_name)
SQS.create_queue(:raw_queue)
SQS.create_queue(:fifo_queue)

add_queue_to_config(build(:queue_config, name: :non_created_queue))
end
Expand All @@ -38,6 +40,11 @@ defmodule ExAwsConfigurator.SQSTest do
assert {:ok, %{status_code: 200}} = SQS.create_queue(:queue_min_config)
end

test "create a fifo queue" do
assert {:ok, %{status_code: 200}} = SQS.create_queue(:fifo_queue)
assert %{attributes: %{fifo_queue: true}} = ExAwsConfigurator.get_queue(:fifo_queue)
end

test "raise when tries to create a queue without configuration" do
assert_raise ExAwsConfigurator.NoResultsError, fn ->
SQS.create_queue(:not_configured_queue)
Expand Down
4 changes: 4 additions & 0 deletions test/support/config_factory.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule ExAwsConfigurator.Factory.Config do
name = Map.get(attrs, :name, :an_queue)
raw_message_delivery = Map.get(attrs, :raw_message_delivery, false)
dead_letter_queue = Map.get(attrs, :dead_letter_queue, true)
fifo_queue = Map.get(attrs, :fifo_queue, false)

queue_config =
%{
Expand All @@ -25,6 +26,9 @@ defmodule ExAwsConfigurator.Factory.Config do
raw_message_delivery: raw_message_delivery,
dead_letter_queue: dead_letter_queue
],
attributes: [
fifo_queue: fifo_queue
],
topics: []
}
|> merge_attributes(attrs)
Expand Down

0 comments on commit ea5818c

Please sign in to comment.