Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polish docs #83

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/broadway_sqs/ex_aws_client.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
defmodule BroadwaySQS.ExAwsClient do
@moduledoc """
Default SQS client used by `BroadwaySQS.Producer` to communicate with AWS
SQS service. This client uses the `ExAws.SQS` library and implements the
SQS service.

This client uses the `ExAws.SQS` library and implements the
`BroadwaySQS.SQSClient` and `Broadway.Acknowledger` behaviours which define
callbacks for receiving and acknowledging messages.
"""
Expand Down
2 changes: 1 addition & 1 deletion lib/broadway_sqs/options.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule BroadwaySQS.Options do
@moduledoc """
Broadway Sqs Option definitions and custom validators.
Broadway SQS option definitions and custom validators.
"""

def definition() do
Expand Down
15 changes: 15 additions & 0 deletions lib/broadway_sqs/sqs_client.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule BroadwaySQS.SQSClient do
@moduledoc """
A generic behaviour to implement SQS Clients for `BroadwaySQS.Producer`.

This module defines callbacks to normalize options and receive message
from a SQS queue. Modules that implement this behaviour should be passed
as the `:sqs_client` option from `BroadwaySQS.Producer`.
Expand All @@ -10,7 +11,21 @@ defmodule BroadwaySQS.SQSClient do

@type messages :: [Message.t()]

@doc """
Should initialize the SQS client.

This callback is called when the producer is started. It should return
`{:ok, normalized_opts}` if the client was initialized successfully or
`{:error, reason}` if there was an error. `normalized_opts` is what gets
passed to the `c:receive_messages/2` callback.
"""
@callback init(opts :: any) :: {:ok, normalized_opts :: any} | {:error, reason :: binary}

@doc """
Should fetch messages from the configured SQS queue.

`opts` is the normalized options returned from `c:init/1`. The `demand`
argument is the number of messages that the producer is asking for.
"""
@callback receive_messages(demand :: pos_integer, opts :: any) :: messages
end
Loading