https://github.com/vishalkuo/e_poller
Yet another SQS long poller
https://github.com/vishalkuo/e_poller
elixir message-queue poller sqs sqs-poller
Last synced: 4 months ago
JSON representation
Yet another SQS long poller
- Host: GitHub
- URL: https://github.com/vishalkuo/e_poller
- Owner: vishalkuo
- License: mit
- Created: 2017-12-04T04:47:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-10T03:40:18.000Z (over 8 years ago)
- Last Synced: 2025-10-21T18:51:22.031Z (8 months ago)
- Topics: elixir, message-queue, poller, sqs, sqs-poller
- Language: Elixir
- Homepage:
- Size: 15.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EPoller
An SQS long poller meant to simulate the functionality seen in the [Ruby SQS SDK](http://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SQS/QueuePoller.html).
[Documentation](https://hexdocs.pm/e_poller/api-reference.html)
### Note About Authentication
If you're planning on using config file authentication, the following needs to be added to your
`config.exs`:
```elixir
config :ex_aws,
access_key_id: [{:system, "AWS_ACCESS_KEY_ID"}, {:awscli, "default", 30}, :instance_role],
secret_access_key: [{:system, "AWS_SECRET_ACCESS_KEY"}, {:awscli, "default", 30}, :instance_role]
```
## Installation
Add `e_poller` to your `mix.exs` file
```elixir
def deps do
[{:e_poller, "~> 0.1.1"}]
end
```
and run `$ mix deps.get`.
## Usage
```elixir
iex(1)> {:ok, poller_pid} = EPoller.start_link("my_worker_queue", fn m -> IO.inspect m end)
{:ok, #PID<0.234.0>}
iex(2)> EPoller.poll(poller_pid)
"1\n"
"1\n2"
"1\n2"
:ok
```
Every poller process is initialized with a queue name and a message handler function. Further configuration, such as region, visibility timeout, and poll duration, can also be configured at this step.
Every time the queue is polled, the handler function is called for each message. If the handler function doesn't raise an error, the message is assumed to have been parsed correctly and the message is deleted from the queue.
### Configuration
Pollers can also be initialized with config variables:
```elixir
iex(1)> config = [wait_time_seconds: 10, visibility_timeout: 2,region: "us-west-1"]
iex(2)> {:ok, poller_pid} = EPoller.start_link("my_worker_queue", fn m -> IO.inspect m end, config)
```