{"id":19829904,"url":"https://github.com/kr00lix/gen_server_async","last_synced_at":"2026-06-13T05:33:07.639Z","repository":{"id":57501697,"uuid":"120576448","full_name":"Kr00lIX/gen_server_async","owner":"Kr00lIX","description":"GenServerAsync allows to run `.call` method in a separate non-blocking GenServer process.","archived":false,"fork":false,"pushed_at":"2020-05-05T10:32:19.000Z","size":27,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T08:24:40.010Z","etag":null,"topics":["elixir","elixir-lang","gen-server","gen-server-async","hex"],"latest_commit_sha":null,"homepage":"","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/Kr00lIX.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":"2018-02-07T07:00:30.000Z","updated_at":"2020-05-05T10:32:21.000Z","dependencies_parsed_at":"2022-09-19T13:51:31.060Z","dependency_job_id":null,"html_url":"https://github.com/Kr00lIX/gen_server_async","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kr00lIX%2Fgen_server_async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kr00lIX%2Fgen_server_async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kr00lIX%2Fgen_server_async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kr00lIX%2Fgen_server_async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kr00lIX","download_url":"https://codeload.github.com/Kr00lIX/gen_server_async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241189021,"owners_count":19924732,"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":["elixir","elixir-lang","gen-server","gen-server-async","hex"],"created_at":"2024-11-12T11:20:38.475Z","updated_at":"2026-06-13T05:33:07.592Z","avatar_url":"https://github.com/Kr00lIX.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GenServerAsync \n-----\n![Elixir CI](https://github.com/Kr00lIX/gen_server_async/workflows/Elixir%20CI/badge.svg)\n[![Hex pm](https://img.shields.io/hexpm/v/gen_server_async.svg?style=flat)](https://hex.pm/packages/gen_server_async)\n[![Coverage Status](https://coveralls.io/repos/github/Kr00lIX/gen_server_async/badge.svg?branch=master)](https://coveralls.io/github/Kr00lIX/gen_server_async?branch=master)\n\n\nGenServerAsync adds a `call_async` method that allows you to run `GenServer.call/3` method in a separate non-blocking GenServer process.\n\n\nExtends the GenServer behavior, adds a `.call_async(server_pid, message)` method to it, which allows you to divide the blocking `handle_call` into three callbacks.\n`handle_call(message, from, state)` –\n\n`handle_call_async(message, call_state)` – asynchronously call this\n\n`handle_cast_async(message, call_async_result, state)` - \n\n```elixir\n# Start the server\n{:ok, pid} = GenServerAsync.start_link(ExampleServer, state)\nGenServerAsync.call_async(pid, message)\n\ndefmodule ExampleServer do\n  use GenServerAsync\n\n  # Makes a synchronous call to the server and waits for its reply.\n  def handle_call(message, from, state) do\n    if could_reply_immediately?(message) do\n      {:reply, response, updated_state}\n    else \n\n      # update state and calls `handle_call_async` asynchronously\n      {:no_reply, updated_state}\n    end\n  end\n\n  @doc \"\"\"\n\n  \"\"\"\n  def handle_call_async(message, call_state) do\n    call_async_result = ... # complex  calculation\n    {:reply, call_async_result}\n  end\n\n  # sync GenServer state after handle_call_async if needed\n  def handle_cast_async(_message, call_async_result, state) do\n    {:noreply, state}\n  end \n  \nend\n```\n\n\n## Installation\nIt's available in Hex, the package can be installed as:\nAdd `gen_server_async` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:gen_server_async, \"\u003e= 0.0.1\"}]\nend\n```\n\nDocumentation can be found at [https://hexdocs.pm/gen_server_async](https://hexdocs.pm/gen_server_async/).\n\n\n## License\nThis software is licensed under [the MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkr00lix%2Fgen_server_async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkr00lix%2Fgen_server_async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkr00lix%2Fgen_server_async/lists"}