ExAwsConfigurator.SQS (ExAwsConfigurator v1.0.3) View Source
Link to this section Summary
Functions
Create an sqs queue based on ex_aws_configurator configuration, that method do NOT subscribe on any topic
Send message to a queue build the correct queue name based on queue configuration
Subscribe an queue into an topic based on clan configuration
Link to this section Functions
Specs
create_queue(atom(), map()) :: {:ok, term()} | {:error, term()}
create_queue(ExAwsConfigurator.Queue.t(), map()) :: {:ok, term()} | {:error, term()}
Create an sqs queue based on ex_aws_configurator configuration, that method do NOT subscribe on any topic
raises ExAwsConfigurator.NoResultsError
if no configuration was found.
for the example below, we will consider the following settings
# config/config.exs
config :ex_aws_configurator,
...
queues: %{
an_queue: %{
environment: "environment",
region: "us-east-1",
prefix: "queue_prefix",
topics: [:an_topic]
}
},
topics: %{
an_topic: %{
region: "us-east-1",
prefix: "topic_prefix",
environment: "environment"
}
}
Examples
ExAwsConfigurator.create_queue(:queue_name)
#=> {:ok, term()}
will create an queue named prefix + environment + map_key
, the result will be queue_prefix_environment_an_queue on region us-east-1
the response term() will be the ExAws
response without any modification
ExAwsConfigurator.get_queue(:not_exist)
#=> ** (ExAwsConfigurator.NoResultsError) the configuration for queue not_exist is not set
Specs
send_message(atom(), String.t(), ExAws.SQS.sqs_message_opts()) :: {:ok, term()} | {:error, term()}
send_message( ExAwsConfigurator.Queue.t(), String.t(), ExAws.SQS.sqs_message_opts() ) :: {:ok, term()} | {:error, term()}
Send message to a queue build the correct queue name based on queue configuration
raises ExAwsConfigurator.NoResultsError
if no configuration was found.
for the example below, we will consider the following settings
# config/config.exs
config :ex_aws_configurator,
...
queues: %{
an_queue: %{
environment: "environment",
region: "us-east-1",
prefix: "queue_prefix",
topics: [:an_topic]
}
}
Examples
ExAwsConfigurator.send_message(:an_queue, "message")
#=> {:ok, term()}
will send a message to queue named queue_prefix_environment_an_queue on region us-east-1
the response term() will be the ExAws
response without any modification
ExAwsConfigurator.send_message(:not_exist)
#=> ** (ExAwsConfigurator.NoResultsError) the configuration for queue not_exist is not set
another possible error is when configuration exists but queue is not created, in this case the response will be {:error, %{status_code: 404, ...}} returned by AWS response
ExAwsConfigurator.send_message(:not_exist)
#=> {:error, term()}
Specs
subscribe(atom(), atom()) :: {:ok, term()} | {:error, term()}
subscribe(ExAwsConfigurator.Queue.t(), ExAwsConfigurator.Topic.t()) :: {:ok, term()} | {:error, term()}
Subscribe an queue into an topic based on clan configuration