{"id":18677241,"url":"https://github.com/elixir-toniq/deadline","last_synced_at":"2025-12-12T00:24:05.786Z","repository":{"id":47338131,"uuid":"289335351","full_name":"elixir-toniq/deadline","owner":"elixir-toniq","description":null,"archived":false,"fork":false,"pushed_at":"2021-09-02T15:31:45.000Z","size":44,"stargazers_count":24,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T22:13:27.890Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/elixir-toniq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-08-21T18:11:26.000Z","updated_at":"2024-07-25T10:51:40.000Z","dependencies_parsed_at":"2022-08-29T19:00:42.200Z","dependency_job_id":null,"html_url":"https://github.com/elixir-toniq/deadline","commit_stats":null,"previous_names":["keathley/deadline"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-toniq%2Fdeadline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-toniq%2Fdeadline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-toniq%2Fdeadline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-toniq%2Fdeadline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-toniq","download_url":"https://codeload.github.com/elixir-toniq/deadline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248506936,"owners_count":21115512,"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","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":[],"created_at":"2024-11-07T09:33:05.259Z","updated_at":"2025-12-12T00:24:05.756Z","avatar_url":"https://github.com/elixir-toniq.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Deadline\n\n\u003c!-- MDOC !--\u003e\n\nDeadline is a small library for managing deadlines and for performing deadline\npropagation across systems. It uses process dictionary both for performance\nand to make the library more ergonomic.\n\n```elixir\n# Set a deadline in milliseconds\nDeadline.set(1_000)\n\n# Schedule this process to exit if the deadline is exceeded.\nDeadline.exit_after()\n\n# Check to see if you've exceeded a deadline...\nif Deadline.reached?() do\n  :cancel\nelse\n  do_some_work()\nend\n\n# Schedule a task and propagate deadlines.\nctx = Deadline.get()\ntask = Task.async(fn -\u003e\n  # Pass the deadline context to the new function.\n  Deadline.set(ctx)\n  do_some_work()\nend)\nTask.await(task, Deadline.time_remaining())\n```\n\n\u003c!-- MDOC !--\u003e\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:deadline, \"~\u003e 0.7\"}\n  ]\nend\n```\n\n## Should I use this?\n\nThis library has been used to serve hundreds of thousands of requests. It's a\nvery small library and thus should be easy to understand if something doesn't\nbehave well. Otherwise you should feel confident to use it in production.\n\nThe only API that might change is the `time_remaining` function. It currently\nreturns `:infinity` if no deadline context has been set. This is probably\nincorrect and we'd prefer to return nil so it can be easily used like so:\n\n```\nTask.await(task, Deadline.time_remaining() || 1_000)\n```\n\nOtherwise, very little in the public API is likely to change.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-toniq%2Fdeadline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-toniq%2Fdeadline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-toniq%2Fdeadline/lists"}