{"action":"created","issue":{"url":"https://api.github.com/repos/nesquena/backburner/issues/100","labels_url":"https://api.github.com/repos/nesquena/backburner/issues/100/labels{/name}","comments_url":"https://api.github.com/repos/nesquena/backburner/issues/100/comments","events_url":"https://api.github.com/repos/nesquena/backburner/issues/100/events","html_url":"https://github.com/nesquena/backburner/pull/100","id":101169403,"number":100,"title":"Added ability to handle all calls to an instance or class method asynchronously","user":{"login":"contentfree","id":10958,"avatar_url":"https://avatars.githubusercontent.com/u/10958?v=3","gravatar_id":"","url":"https://api.github.com/users/contentfree","html_url":"https://github.com/contentfree","followers_url":"https://api.github.com/users/contentfree/followers","following_url":"https://api.github.com/users/contentfree/following{/other_user}","gists_url":"https://api.github.com/users/contentfree/gists{/gist_id}","starred_url":"https://api.github.com/users/contentfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contentfree/subscriptions","organizations_url":"https://api.github.com/users/contentfree/orgs","repos_url":"https://api.github.com/users/contentfree/repos","events_url":"https://api.github.com/users/contentfree/events{/privacy}","received_events_url":"https://api.github.com/users/contentfree/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-15T11:59:14Z","updated_at":"2015-09-07T20:22:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nesquena/backburner/pulls/100","html_url":"https://github.com/nesquena/backburner/pull/100","diff_url":"https://github.com/nesquena/backburner/pull/100.diff","patch_url":"https://github.com/nesquena/backburner/pull/100.patch"},"body":"Allows the developer to configure async usage separately from their code. This is especially useful when you only want asynchronous behavior in a particular environment. Inspired heavily by the same concept in Delayed::Job\r\n\r\nExample:\r\n```ruby\r\nclass Example\r\n  def id: 1 end\r\n  def hard_task; \"…work…\" end\r\nend\r\n\r\n# In a production config, perhaps:\r\nBackburner::Performable.handle_asynchronously(Example, :hard_task)\r\n\r\n# Now, this will use #async automagically:\r\nExample.new.hard_task\r\n```\r\n\r\nThere's also a way to handle class methods:\r\n```ruby\r\nclass Example\r\n  def self.hard_task; \"…work…\" end\r\nend\r\n\r\n# Elsewhere:\r\nBackburner::Performable.handle_static_asynchronously(Example, :hard_task)\r\n\r\n# It now uses #async\r\nExample.hard_task\r\n```\r\n\r\nNB: If the producer and consumer are not configured the same way – eg. the producer uses `#handle_asynchronously` in its setup but the consumer doesn't – then the consumer will need to know that the method stored in beanstalkd has a suffix of \"_without_async\". (In the first example above, Backburner will actually store the method name as `:hard_task_without_async`.) This seems like a rare edge case, but it's imaginable."},"comment":{"url":"https://api.github.com/repos/nesquena/backburner/issues/comments/138370311","html_url":"https://github.com/nesquena/backburner/pull/100#issuecomment-138370311","issue_url":"https://api.github.com/repos/nesquena/backburner/issues/100","id":138370311,"user":{"login":"nesquena","id":6511,"avatar_url":"https://avatars.githubusercontent.com/u/6511?v=3","gravatar_id":"","url":"https://api.github.com/users/nesquena","html_url":"https://github.com/nesquena","followers_url":"https://api.github.com/users/nesquena/followers","following_url":"https://api.github.com/users/nesquena/following{/other_user}","gists_url":"https://api.github.com/users/nesquena/gists{/gist_id}","starred_url":"https://api.github.com/users/nesquena/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nesquena/subscriptions","organizations_url":"https://api.github.com/users/nesquena/orgs","repos_url":"https://api.github.com/users/nesquena/repos","events_url":"https://api.github.com/users/nesquena/events{/privacy}","received_events_url":"https://api.github.com/users/nesquena/received_events","type":"User","site_admin":false},"created_at":"2015-09-07T20:22:51Z","updated_at":"2015-09-07T20:22:51Z","body":"In my view, calling a class method on a module feels awkward and its unclear where you would call that line. This resque implementation https://gist.github.com/jdhollis/432220 also works within the class as does the delayed_job implementation.  I prefer consistency with what people have used unless it's a significant improvement. "}}