{"action":"opened","issue":{"url":"https://api.github.com/repos/utgarda/sidekiq-status/issues/135","repository_url":"https://api.github.com/repos/utgarda/sidekiq-status","labels_url":"https://api.github.com/repos/utgarda/sidekiq-status/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/utgarda/sidekiq-status/issues/135/comments","events_url":"https://api.github.com/repos/utgarda/sidekiq-status/issues/135/events","html_url":"https://github.com/utgarda/sidekiq-status/issues/135","id":336417083,"node_id":"MDU6SXNzdWUzMzY0MTcwODM=","number":135,"title":"Doesn't work if multiple services share the same redis","user":{"login":"albertosaurus","id":854655,"node_id":"MDQ6VXNlcjg1NDY1NQ==","avatar_url":"https://avatars3.githubusercontent.com/u/854655?v=4","gravatar_id":"","url":"https://api.github.com/users/albertosaurus","html_url":"https://github.com/albertosaurus","followers_url":"https://api.github.com/users/albertosaurus/followers","following_url":"https://api.github.com/users/albertosaurus/following{/other_user}","gists_url":"https://api.github.com/users/albertosaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/albertosaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albertosaurus/subscriptions","organizations_url":"https://api.github.com/users/albertosaurus/orgs","repos_url":"https://api.github.com/users/albertosaurus/repos","events_url":"https://api.github.com/users/albertosaurus/events{/privacy}","received_events_url":"https://api.github.com/users/albertosaurus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-27T23:02:45Z","updated_at":"2018-06-27T23:02:45Z","closed_at":null,"author_association":"NONE","body":"From this page: https://github.com/mperham/sidekiq/wiki/Middleware\r\n\r\n> Obscure Scenario: If you share a single redis instance between multiple services, and use client-side middleware on your Sidekiq server, be warned that it might have to deal with workers from unexpected queues. Sidekiq uses a singe redis set to handle scheduled workers, and any server might requeue a worker that's due to be processed, even if it's not for a queue it was configured to process. When it does so, your middleware might be passed a worker name that does not exist in the current ruby context and you might see uninitialized constant exceptions or similar errors.\r\n\r\nSince version 0.8.0 the middleware client is doing a `Module.const_get` without handling any potential `NameError`. This causes annoying breakage. I'd like to propose something like this:\r\n\r\n```ruby\r\n  def call(worker_class, msg, queue, redis_pool=nil)\r\n\r\n    # Determine the actual job class\r\n    klass = msg[\"args\"][0][\"job_class\"] || worker_class rescue worker_class\r\n\r\n    job_class = if klass.is_a?(Class)\r\n                  klass\r\n                elsif Module.const_defined?(klass) # Ensure constant is defined before attempting access \r\n                  Module.const_get(klass)\r\n                else\r\n                  nil\r\n                end\r\n\r\n    # Store data if the job is a Sidekiq::Status::Worker\r\n    if job_class && job_class.ancestors.include?(Sidekiq::Status::Worker)\r\n      initial_metadata = {\r\n        jid: msg['jid'],\r\n        status: :queued,\r\n        worker: Sidekiq::Job.new(msg, queue).display_class,\r\n        args: display_args(msg, queue)\r\n      }\r\n      store_for_id msg['jid'], initial_metadata, job_class.new.expiration || @expiration, redis_pool\r\n    end\r\n\r\n    yield\r\n\r\n  end\r\n\r\nend\r\n```"}}
{"actor":{"display_login":"albertosaurus"}}