{"id":32164355,"url":"https://github.com/bschaeffer/timeout","last_synced_at":"2026-02-18T21:02:19.303Z","repository":{"id":62430455,"uuid":"104783423","full_name":"bschaeffer/timeout","owner":"bschaeffer","description":"A module for configurable timeouts in Elixir.","archived":false,"fork":false,"pushed_at":"2018-03-02T15:00:16.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-21T14:50:52.765Z","etag":null,"topics":["elixir","timeouts"],"latest_commit_sha":null,"homepage":"https://hexdocs.pm/timeout","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bschaeffer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T17:55:45.000Z","updated_at":"2022-01-27T23:17:07.000Z","dependencies_parsed_at":"2022-11-01T20:21:40.716Z","dependency_job_id":null,"html_url":"https://github.com/bschaeffer/timeout","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bschaeffer/timeout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bschaeffer%2Ftimeout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bschaeffer%2Ftimeout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bschaeffer%2Ftimeout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bschaeffer%2Ftimeout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bschaeffer","download_url":"https://codeload.github.com/bschaeffer/timeout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bschaeffer%2Ftimeout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29596125,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T20:59:56.587Z","status":"ssl_error","status_checked_at":"2026-02-18T20:58:41.434Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","timeouts"],"created_at":"2025-10-21T14:45:04.142Z","updated_at":"2026-02-18T21:02:19.291Z","avatar_url":"https://github.com/bschaeffer.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Timeout\n\n[![CircleCI](https://circleci.com/gh/bschaeffer/timeout.svg?style=svg)](https://circleci.com/gh/bschaeffer/timeout)\n[![hex.pm](https://img.shields.io/hexpm/v/timeout.svg \"Hex version\")](https://hex.pm/packages/timeout)\n\n\n`Timeout` is an api for managing and manipulating configurable timeouts. It was\nmainly built as a library to configure a timeout once, then start scheduling\nmessages based on the configuration. It's features include:\n\n* API for retrieving and iterating timeouts.\n* Timeout backoff with optional max.\n* Randomizing within a given percent of a desired range.\n* Timer management utilizing the above configuration.\n\nRead the docs at https://hexdocs.pm/timeout.\n\n## Example Usage\n\nA simple example using a `GenServer` process polling a remote service for work:\n\n```elixir\ndefmodule MyPoller do\n  use GenServer\n  require Logger\n\n  def start_link(backend) do\n    GenServer.start_link(__MODULE__, [backend])\n  end\n\n  def init(backend) do\n    timeout =\n      Timeout.new(50, backoff: 1.25, backoff_max: 1_250, random: 0.1)\n      |\u003e Timeout.send_after(self(), :poll)\n\n    {:ok, %{backend, timeout}}\n  end\n\n  def handle_info(:poll, {backend, timeout}) do\n    case backend.poll() do\n      {:ok, job} -\u003e\n        # Process job. Reset timeout to poll at the initial interval.\n        timeout = Timeout.reset() |\u003e Timeout.send_after!(:poll)\n        {:noreply, {backend, timeout}}\n      :empty -\u003e\n        # No work to do. Send after automatically increases the backoff\n        {timeout, delay} = timeout |\u003e Timeout.send_after(:poll)\n        Logger.debug(\"No work. Retrying in #{delay}ms\")\n        {:noreply, {backend, timeout}}\n    end\n  end\n\n  def handle_info({:new_job, job}, {backend, timeout}) do\n    Timeout.cancel_timer!(timeout)\n    # Process job\n    timeout = timeout |\u003e Timeout.reset() |\u003e Timeout.send_after!(:poll)\n    {:noreply, {backend, timeout}}\n  end\nend\n```\n\nSee the docs for more information: https://hexdocs.pm/timeout.\n\n## Installation\n\nAdd `timeout` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [\n    {:timeout, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\n[thp]: https://en.wikipedia.org/wiki/Thundering_herd_problem\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbschaeffer%2Ftimeout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbschaeffer%2Ftimeout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbschaeffer%2Ftimeout/lists"}