Closed arjan closed 5 months ago
Setting default opts
defines both a new/1
and new/2
, and it correctly warns that new/1
already exists.
You should only define new/2
:
@impl Oban.Worker
def new(args, opts) do
args
|> Map.put(:foo, 1)
|> super(opts)
end
That clause will still be used when you call MyWorker.new(args)
.
Ah yes, of course, thanks for the explanation!
Current Behavior
When creating a custom new/2 function on a worker, a compilation warning is raised. Easily reproducible with this script:
The warning that is thrown is this one:
I think it has to do with the defaults on the second argument. The warning goes away if I add a
@callback
declaration for the new/1 inOban.Worker
, next to the existing callback:But I am not sure that this is a proper solution.