{"id":32167459,"url":"https://github.com/rfunix/lix","last_synced_at":"2025-10-21T15:32:09.598Z","repository":{"id":57517375,"uuid":"143290356","full_name":"rfunix/lix","owner":"rfunix","description":"OTP Library for create generic SQS worker handlers","archived":false,"fork":false,"pushed_at":"2018-11-01T01:07:37.000Z","size":93,"stargazers_count":13,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T00:55:21.458Z","etag":null,"topics":["elixir","elixir-library","handler","otp-library","sqs","worker"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rfunix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-02T12:15:15.000Z","updated_at":"2024-07-20T06:34:44.000Z","dependencies_parsed_at":"2022-09-15T21:23:38.675Z","dependency_job_id":null,"html_url":"https://github.com/rfunix/lix","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/rfunix/lix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfunix%2Flix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfunix%2Flix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfunix%2Flix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfunix%2Flix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rfunix","download_url":"https://codeload.github.com/rfunix/lix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rfunix%2Flix/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280286295,"owners_count":26304700,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","elixir-library","handler","otp-library","sqs","worker"],"created_at":"2025-10-21T15:30:39.803Z","updated_at":"2025-10-21T15:32:09.577Z","avatar_url":"https://github.com/rfunix.png","language":"Elixir","readme":"# Lix [![CircleCI](https://circleci.com/gh/rfunix/lix/tree/master.svg?style=svg)](https://circleci.com/gh/rfunix/lix/tree/master)\n\n# Lix is a generic worker handler for SQS messages.\n\n## Installation\n\n1. Add Lix to your dependencies in the `mix.exs` file:\n\n```elixir\ndef deps do\n  [\n    {:lix, git: \"https://github.com/rfunix/lix/\", tag: \"0.2.0\"},\n  ]\nend\n```\n\n2. Run `$ mix deps.get` to update your dependencies.\n\n3. Add `:lix` to your extra applications list:\n\n```elixir\ndef application do\n  [extra_applications: [:lix]]\nend\n```\n\n## Configuration\n\nLix uses [ex_aws_sqs](https://github.com/ex-aws/ex_aws_sqs) to handle SQS messages and [ex_aws_sns](https://github.com/ex-aws/ex_aws_sns) to publish messages.\n\nFor this to work, we need to add a few AWS settings in our file `config.exs`. For example:\n\n```elixir\nconfig :ex_aws, :sqs,\n  access_key_id: \"\",\n  secret_access_key: \"\",\n  scheme: \"http://\",\n  host: \"localhost\",\n  port: 4100,\n  region: \"local-01\"\n  \nconfig :ex_aws, :sns,\n  access_key_id: \"\",\n  secret_access_key: \"\",\n  scheme: \"http://\",\n  host: \"localhost\",\n  port: 4100,\n  region: \"local-01\"\n```\n\nFor Newrelic add your app_name and license_key as the example below:\n```elixir\nconfig :new_relic_agent,\n  app_name: \"My App\",\n  license_key: \"license_key\"\n```\n\nYou can also define some Lix specific settings. For example:\n```elixir\nconfig :lix,\n  max_number_of_messages: 10,\n  visibility_timeout: 0.30,\n  handler_backoff: 500\n```\n\n## Examples\n\n### Basic Worker\n\n```elixir\n\ndefmodule Basic.Handler.Example do\n  use GenServer\n\n  @name :handler_example\n\n  def start_link(args) do\n    GenServer.start_link(__MODULE__, args, name: @name)\n  end\n\n  @impl true\n  def init(args) do\n    Lix.Handler.Manager.register(%{\n      handler_example: [queue: \"queue/handler_queue\", callback: \"process_item\"]\n    })\n\n    schedule_poller()\n    {:ok, args}\n  end\n\n  defp schedule_poller() do\n    send(self(), :poll)\n  end\n\n  @impl true\n  def handle_info(:poll, state) do\n    Lix.Handler.run(@name)\n    schedule_poller()\n    {:noreply, state}\n  end\n\n  @impl true\n  def handle_cast({:process_item, messages}, state) do\n    # Do things\n    Enum.map(messages, fn message -\u003e\n      Lix.Handler.confirm_processed_callback(@name, message)\n    end)\n\n    {:noreply, state}\n  end\nend\n\n```\n\n### Basic Worker that publishes SNS messages\n\n```elixir\ndefmodule Basic.Handler.Example do\n  use GenServer\n\n  @name :handler_example\n\n  def start_link(args) do\n    GenServer.start_link(__MODULE__, args, name: @name)\n  end\n\n  @impl true\n  def init(args) do\n    Lix.Handler.Manager.register(%{\n      handler_example: [queue: \"queue/handler_queue\", callback: \"process_item\", topic_arn: \"my-topic\"]\n    })\n\n    schedule_poller()\n    {:ok, args}\n  end\n\n  defp schedule_poller() do\n    send(self(), :poll)\n  end\n\n  @impl true\n  def handle_info(:poll, state) do\n    Lix.Handler.run(@name)\n    schedule_poller()\n    {:noreply, state}\n  end\n\n  @impl true\n  def handle_cast({:process_item, messages}, state) do\n    # Do things\n    Enum.map(messages, fn message -\u003e\n      Lix.Handler.confirm_processed_callback(@name, message, \"PUBLISH THIS MESSAGE\")\n    end)\n\n    {:noreply, state}\n  end\nend\n```\n\n### Workers\n\n```elixir\n\ndefmodule Example.Handler.Supervisor do\n  use Supervisor\n\n  @number_of_workers 1..5\n\n  def start_link(arg) do\n    Supervisor.start_link(__MODULE__, arg, name: __MODULE__)\n  end\n\n  @impl true\n  def init(_arg) do\n    children = Enum.map(@number_of_workers, fn worker_number -\u003e \n      name = String.to_atom(\"handler#{worker_number}\")\n      Supervisor.child_spec({Example.Handler, %{name: name, queue: \"test_item\"}}, id: name)\n    end)\n\n    Supervisor.init(children, strategy: :one_for_one)\n  end\nend\n\ndefmodule Example.Handler do\n  use GenServer\n  require Logger\n\n  def start_link(%{name: name} = args) do\n    GenServer.start_link(__MODULE__, args, name: name)\n  end\n\n  @impl true\n  def init(args) do\n    generate_handler_info(args)\n    |\u003e Lix.Handler.Manager.register()\n\n    schedule_poller()\n    {:ok, args}\n  end\n\n  defp generate_handler_info(%{name: name, queue: queue}) do\n    AtomicMap.convert(%{name =\u003e [queue: \"queue/#{queue}\", callback: \"process_item\"]})\n  end\n\n  defp schedule_poller() do\n    send(self(), :poll)\n  end\n\n  @impl true\n  def handle_info(:poll, %{name: name} = state) do\n    Lix.Handler.run(name)\n    schedule_poller()\n    {:noreply, state}\n  end\n\n  @impl true\n  def handle_cast({:process_item, messages}, %{name: name} = state) do\n    # Do things\n    Enum.map(messages, fn message -\u003e\n      Lix.Handler.confirm_processed_callback(name, message)\n    end)\n\n    {:noreply, state}\n  end\nend\n\nExample.Handler.Supervisor.start_link([])\n```\n\nThe documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc)\nand published on [HexDocs](https://hexdocs.pm). Once published, the docs can\nbe found at [https://hexdocs.pm/lix](https://hexdocs.pm/lix).\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frfunix%2Flix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frfunix%2Flix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frfunix%2Flix/lists"}