{"id":22944445,"url":"https://github.com/hqoss/pool_lad","last_synced_at":"2025-08-12T22:32:01.016Z","repository":{"id":57535710,"uuid":"265904773","full_name":"hqoss/pool_lad","owner":"hqoss","description":"🙅‍♂️ The younger \u0026 more energetic version of :poolboy","archived":false,"fork":false,"pushed_at":"2020-05-24T19:42:10.000Z","size":33,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-20T20:41:45.775Z","etag":null,"topics":["elixir","elixir-lang","elixir-library","pool","poolboy","worker-pool"],"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/hqoss.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-05-21T17:00:24.000Z","updated_at":"2024-07-20T06:44:56.000Z","dependencies_parsed_at":"2022-08-29T00:41:00.034Z","dependency_job_id":null,"html_url":"https://github.com/hqoss/pool_lad","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hqoss%2Fpool_lad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hqoss%2Fpool_lad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hqoss%2Fpool_lad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hqoss%2Fpool_lad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hqoss","download_url":"https://codeload.github.com/hqoss/pool_lad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229711362,"owners_count":18112118,"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","elixir-library","pool","poolboy","worker-pool"],"created_at":"2024-12-14T14:18:39.849Z","updated_at":"2024-12-14T14:18:40.543Z","avatar_url":"https://github.com/hqoss.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Elixir CI](https://github.com/hqoss/pool_lad/workflows/Elixir%20CI/badge.svg)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4cfbf336d5914e09971c015bd68426a0)](https://www.codacy.com/gh/hqoss/pool_lad?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=hqoss/pool_lad\u0026utm_campaign=Badge_Grade)\n[![Hex.pm](https://img.shields.io/hexpm/v/pool_lad.svg)](https://hex.pm/packages/pool_lad)\n[![Coverage Status](https://coveralls.io/repos/github/hqoss/pool_lad/badge.svg?branch=master)](https://coveralls.io/github/hqoss/pool_lad?branch=master)\n\n# 🙅‍♂️ PoolLad\n\n`pool_lad` is the younger \u0026 more energetic version of [`poolboy`](https://github.com/devinus/poolboy).\n\nIt's still the _**lightweight, generic pooling library with focus on\nsimplicity, performance, and rock-solid disaster recovery**_ that we all love...\n\n...but it has just gotten a much needed facelift!\n\n## Table of contents\n\n-   [Installation](#installation)\n\n-   [API Documentation](#api-documentation)\n\n-   [Sample usage](#sample-usage)\n\n-   [Example application](#example-application)\n\n    -   [Define a worker server](#define-a-worker-server)\n    -   [Start the pool](#start-the-pool)\n    -   [Do the work](#do-the-work)\n\n-   [`pool_lad` over `poolboy`](#pool_lad-over-poolboy)\n\n-   [TODO](#todo)\n\n## Installation\n\nAdd `:pool_lad` as a dependency to your project's `mix.exs`:\n\n```elixir\ndefp deps do\n  [\n    {:pool_lad, \"~\u003e 0.0.5\"}\n  ]\nend\n```\n\n## API Documentation\n\nThe full documentation is [published on hex](https://hexdocs.pm/pool_lad/PoolLad.html).\n\n## Sample usage\n\nThe APIs are almost identical to those of [`:poolboy`](https://github.com/devinus/poolboy).\n\nVia manual ownership:\n\n```elixir\niex(1)\u003e {:ok, pid} = PoolLad.borrow(MyWorkerPool)\n{:ok, #PID\u003c0.229.0\u003e}\niex(2)\u003e GenServer.call(pid, :get_latest_count)\n{:ok, 42}\niex(3)\u003e PoolLad.return(MyWorkerPool, pid)\n:ok\n```\n\nVia transactional ownership:\n\n```elixir\niex(1)\u003e PoolLad.transaction(\n  MyWorkerPool,\n  fn pid -\u003e GenServer.call(pid, :get_latest_count) end\n)\n{:ok, 42}\n```\n\n## Example application\n\n### Define a worker server\n\n```elixir\ndefmodule MyWorker do\n  @moduledoc false\n\n  use GenServer\n\n  @this_module __MODULE__\n\n  def start_link(opts), do: GenServer.start_link(@this_module, opts)\n\n  @impl true\n  def init(opts) do\n    initial_colours = Keyword.get(opts, :initial_colours, [])\n    {:ok, initial_colours}\n  end\n\n  @impl true\n  def handle_call(:get_random_colour, _from, colours) do\n    colour = Enum.random(colours)\n    {:reply, colour, colours}\n  end\nend\n```\n\n### Start the pool\n\n```elixir\npool_opts = [\n  name: MyWorkerPool,\n  worker_count: 3,\n  worker_module: MyWorker\n]\n\nworker_opts = [initial_colours: ~w(red green blue)a]\n\nchildren = [\n  PoolLad.child_spec(pool_opts, worker_opts)\n]\n\nopts = [strategy: :one_for_one, name: MyApp.Supervisor]\nSupervisor.start_link(children, opts)\n```\n\n### Do the work\n\nVia manual ownership:\n\n```elixir\niex(1)\u003e {:ok, worker} = PoolLad.borrow(MyWorkerPool)\n{:ok, #PID\u003c0.256.0\u003e}\niex(2)\u003e GenServer.call(worker, :get_random_colour)\n:blue\niex(3)\u003e PoolLad.return(MyWorkerPool, worker)\n:ok\n```\n\nVia transactional ownership:\n\n```elixir\niex(1)\u003e PoolLad.transaction(\n...(1)\u003e   MyWorkerPool,\n...(1)\u003e   fn worker -\u003e GenServer.call(worker, :get_random_colour) end\n...(1)\u003e )\n:green\n```\n\n## `pool_lad` over `poolboy`\n\n-   Elixir-first\n-   Modern APIs, e.g. `DynamicSupervisor`\n-   Less code, less pesky logs, less noise\n-   More documentation\n-   Same performance\n-   Maintained\n-   0 dependencies\n\n## TODO\n\nA quick and dirty tech-debt tracker, used in conjunction with Issues.\n\n-   [ ] Add overflow functionality\n-   [ ] Beautify PoolLad over :poolboy section\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhqoss%2Fpool_lad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhqoss%2Fpool_lad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhqoss%2Fpool_lad/lists"}