Open synthead opened 8 years ago
Seems odd. I haven't looked at the code in a year or so. I'll take a look.
Scratch that, it looks like it doesn't accept redis://127.0.0.1:6379
as well, so it's not limited to sockets.
@synthead I couldn't replicate. So I created a demo app to test. I had never configured redis to use sockets before so I had to learn that. Thank you. You can find the demo app here. https://github.com/erickrause/activejob-locks-example
Wow, this is really great! Thank you! I'll dig into the repo tomorrow and compare it to my project piece-by-piece to see what's going on here.
Oh gross, you know what the issue is? I'm also using websocket-rails and it is throwing this exception regardless that these jobs have nothing to do with it. I added the websocket-rails gem to the project, and without even calling it at all, it breaks ActiveJob. Yikes!
I didn't mention it because I didn't think it had anything to do with this issue, but it totally does. Sorry to bother; you've been awesome.
Actually, now that I realize it, it looks like this only happens when lock_by
is called in a job. This might be websocket-rails or activejob-locks; I'm not sure. Perhaps the logic for activejob-locks could be contained in a namespace in Redis or something?
Here, check out this branch (forked from your repository). Notice that LockedJob.perform_now("foo")
from a rails console displays this output:
Performing LockedJob from Sidekiq(default) with arguments: "foof"
Performed LockedJob from Sidekiq(default) in 2.58ms
RuntimeError: eventmachine not initialized: evma_connect_to_server
from /home/fred/.gem/ruby/2.3.0/gems/eventmachine-1.2.0.1/lib/eventmachine.rb:677:in `connect_server'
...but when the lock_by
line is commented-out, the job runs just fine:
Performing LockedJob from Sidekiq(default) with arguments: "foo"
awesome foo
Performed LockedJob from Sidekiq(default) in 15004.9ms
=> nil
In
config/application.rb
, as suggested byREADME.md
......(where
config/redis.yml
contains):...if I have this job:
...and I queue it up in Sidekiq via the vanilla ActiveJob implementation, I get this in my logs:
...with the key lines being: