# `Kombu.Resource`
[🔗](https://github.com/hacktobeer/kombu/blob/v0.1.0/lib/kombu/pools.ex#L1)

Generic LIFO resource pool (`kombu.resource.Resource`).

# `t`

```elixir
@type t() :: %Kombu.Resource{
  close_fun: term(),
  collect_fun: term(),
  limit_exception: term(),
  new_fun: term(),
  pid: term(),
  prepare_fun: term(),
  release_fun: term()
}
```

# `acquire`

```elixir
@spec acquire(t(), keyword()) :: term()
```

Acquires a resource from `pool` (`Resource.acquire`).

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `force_close_all`

```elixir
@spec force_close_all(t(), keyword()) :: :ok
```

Closes and removes all resources in the pool, including those currently in use
(`Resource.force_close_all`).

# `limit`

```elixir
@spec limit(t()) :: non_neg_integer() | nil
```

Returns the current pool limit.

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates a new `%Kombu.Resource{}` pool process.

# `release`

```elixir
@spec release(t(), term()) :: :ok
```

Releases `resource` back to `pool` (`Resource.release`).

# `replace`

```elixir
@spec replace(t(), term()) :: :ok
```

Discards a defective `resource` from `pool` and closes it (`Resource.replace`).

# `resize`

```elixir
@spec resize(t(), non_neg_integer() | nil, keyword()) :: :ok
```

Resizes the pool limit (`Resource.resize`).

# `setup`

```elixir
@spec setup(t()) :: :ok
```

Pre-populates the pool with lazy resource factories up to `limit - dirty`.

# `validate_limit!`

# `with_resource`

```elixir
@spec with_resource(t(), keyword(), (term() -&gt; result)) :: result when result: var
```

Acquires a resource, passes it to `fun.(resource)`, and ensures it is released afterwards.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
