Skip to content

vishalkuo/e_poller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EPoller

An SQS long poller meant to simulate the functionality seen in the Ruby SQS SDK.

Documentation

Note About Authentication

If you're planning on using config file authentication, the following needs to be added to your config.exs:

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

def deps do
  [{:e_poller, "~> 0.1.1"}]
end

and run $ mix deps.get.

Usage

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:

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)

Releases

No releases published

Packages

No packages published

Languages