Skip to content

Adding NimblePool as a supervisor child #25

Description

@maartenJacobs

The README states that the following should work:

children = [
  {GenMagic.Pool.NimblePool, pool_name: MyApp.GenMagicPool, pool_size: 2}
]

opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)

But Supervisor runs child_spec/1 on its children, giving me this error:

** (Mix) Could not start application gen_magic_test: exited in: GenMagicTest.Application.start(:normal, [])
    ** (EXIT) an exception was raised:
        ** (ArgumentError) The module GenMagic.Pool.NimblePool was given as a child to a supervisor
but it does not implement child_spec/1.

I'm happy to provide a PR. I think there are at least possible 2 solutions:

  • The Pool behaviour requires child_spec/1.
  • The README is updated to include the child spec:
%{
  id: GenMagic.Pool.NimblePool,
  start: {GenMagic.Pool.NimblePool, :start_link, [[pool_name: MyApp.GenMagicPool, pool_size: 2]]}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions