Skip to content

Commit

Permalink
Polish docs
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide committed Feb 20, 2024
1 parent 99c7a21 commit 65723ed
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
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

0 comments on commit 65723ed

Please sign in to comment.