Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed release of workers #55

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.4] - 2023-07-23
### Fixed

- Fixed a serious bug when working with the `idle_workers` set. Previous version retired.

## [0.7.4] - 2023-07-23 (RETIRED)

### Fixed

Expand Down Expand Up @@ -133,7 +137,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix links in hex documentation.
- Added missing spec for `get_debug_info/1`.

## [0.3.0] - 2023-02-03
## [0.3.0] - 2023-02-03 (RETIRED)

### Added

Expand Down
2 changes: 1 addition & 1 deletion lib/poolex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ defmodule Poolex do
| idle_workers_state:
IdleWorkers.add(
state.idle_workers_impl,
state.busy_workers_state,
state.idle_workers_state,
worker
)
}
Expand Down
18 changes: 18 additions & 0 deletions test/poolex_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ defmodule PoolexTest do
assert debug_info.waiting_callers_impl == SomeWaitingCallersImpl
end

test "valid after using the worker" do
initial_fun = fn -> 0 end
pool_name = start_pool(worker_module: Agent, worker_args: [initial_fun], workers_count: 5)

{:ok, 0} = Poolex.run(pool_name, fn pid -> Agent.get(pid, & &1) end)

debug_info = Poolex.get_debug_info(pool_name)

assert debug_info.__struct__ == Poolex.DebugInfo
assert debug_info.busy_workers_count == 0
assert Enum.empty?(debug_info.busy_workers_pids)
assert debug_info.idle_workers_count == 5
assert Enum.count(debug_info.idle_workers_pids) == 5
assert debug_info.worker_module == Agent
assert debug_info.worker_args == [initial_fun]
assert debug_info.waiting_callers == []
end

test "valid after holding some workers" do
initial_fun = fn -> 0 end
pool_name = start_pool(worker_module: Agent, worker_args: [initial_fun], workers_count: 5)
Expand Down
Loading