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

Guardian.DB.Sweeper incompatible with old worker API #144

Open
RichDom2185 opened this issue Sep 17, 2023 · 1 comment
Open

Guardian.DB.Sweeper incompatible with old worker API #144

RichDom2185 opened this issue Sep 17, 2023 · 1 comment

Comments

@RichDom2185
Copy link
Contributor

Steps to Reproduce

Configure using the old (deprecated) worker(...) notation (as defined in the examples in lib/guardian/db.ex):

children = [
  worker(Guardian.DB.Sweeper, [interval: 60])
]

Expected Result

Configures the worker correctly, just like as if it were called using the new notation (as defined in the README):

children = [
  {Guardian.DB.Sweeper, [interval: 60]}
]

Actual Result

shutdown: failed to start child: Guardian.DB.Sweeper
    ** (EXIT) an exception was raised:
        ** (FunctionClauseError) no function clause matching in Keyword.get/3
            (elixir 1.13.4) lib/keyword.ex:352: Keyword.get({:interval, 180000}, :interval, 3600000)
            (guardian_db 3.0.0) lib/guardian/db/sweeper.ex:19: Guardian.DB.Sweeper.start_link/1
            (stdlib 4.3.1) supervisor.erl:414: :supervisor.do_start_child_i/3
            (stdlib 4.3.1) supervisor.erl:400: :supervisor.do_start_child/2
            (stdlib 4.3.1) supervisor.erl:384: anonymous fn/3 in :supervisor.start_children/2
            (stdlib 4.3.1) supervisor.erl:1250: :supervisor.children_map/4
            (stdlib 4.3.1) supervisor.erl:350: :supervisor.init_children/2
            (stdlib 4.3.1) gen_server.erl:851: :gen_server.init_it/2
            (stdlib 4.3.1) gen_server.erl:814: :gen_server.init_it/6
            (stdlib 4.3.1) proc_lib.erl:240: :proc_lib.init_p_do_apply/3
@yordis
Copy link
Member

yordis commented Sep 17, 2023

Weird, I do not see the child_spec but it works doing the following:

test "testing supervisor" do
    children = [
      {Guardian.DB.Sweeper, [interval: 60 * 60 * 1000]}
    ]

    assert {:ok, pid} = Supervisor.start_link(children, strategy: :one_for_one)
    assert %{active: 1, specs: 1, supervisors: 0, workers: 1} = Supervisor.count_children(pid)
  end

What elixir and erlang version are you using?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants