{"action":"created","issue":{"url":"https://api.github.com/repos/brandonhilkert/sucker_punch/issues/172","repository_url":"https://api.github.com/repos/brandonhilkert/sucker_punch","labels_url":"https://api.github.com/repos/brandonhilkert/sucker_punch/issues/172/labels{/name}","comments_url":"https://api.github.com/repos/brandonhilkert/sucker_punch/issues/172/comments","events_url":"https://api.github.com/repos/brandonhilkert/sucker_punch/issues/172/events","html_url":"https://github.com/brandonhilkert/sucker_punch/issues/172","id":143748300,"number":172,"title":"ActiveJob future support","user":{"login":"cshupp1","id":5719570,"avatar_url":"https://avatars.githubusercontent.com/u/5719570?v=3","gravatar_id":"","url":"https://api.github.com/users/cshupp1","html_url":"https://github.com/cshupp1","followers_url":"https://api.github.com/users/cshupp1/followers","following_url":"https://api.github.com/users/cshupp1/following{/other_user}","gists_url":"https://api.github.com/users/cshupp1/gists{/gist_id}","starred_url":"https://api.github.com/users/cshupp1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshupp1/subscriptions","organizations_url":"https://api.github.com/users/cshupp1/orgs","repos_url":"https://api.github.com/users/cshupp1/repos","events_url":"https://api.github.com/users/cshupp1/events{/privacy}","received_events_url":"https://api.github.com/users/cshupp1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-03-26T20:48:20Z","updated_at":"2016-07-20T15:06:51Z","closed_at":"2016-03-26T21:25:47Z","body":"Currently, in sucker_punch_adapter.rb,  the class SuckerPunchAdapter has the following method and implementation:\r\n\r\n```\r\n        def enqueue_at(job, timestamp) #:nodoc:\r\n          raise NotImplementedError\r\n        end\r\n```\r\n\r\nThis means when using with ActiveJob (rails 4.2.x) that syntax like this:\r\n```\r\nArtifactDownloadJob.set(wait_until: 5.seconds.from_now).perform_later\r\n```\r\nwill not function.\r\n\r\nHere is a monkey patch that works in JRuby. I have the following initializer file 'sucker_punch.rb':\r\n```\r\nrequire 'sucker_punch/async_syntax'\r\n\r\njava_import 'java.util.Timer' do |p, c|\r\n  'JTimer'\r\nend\r\n\r\njava_import 'java.util.TimerTask' do |p, c|\r\n  'JTimerTask'\r\nend\r\n\r\nclass TimerTask < JTimerTask\r\n\r\n  def set_runnable(task_lambda)\r\n    @lamb = task_lambda\r\n  end\r\n\r\n  def run\r\n    @lamb.call\r\n  end\r\n\r\nend\r\n\r\nmodule ActiveJob\r\n  module QueueAdapters\r\n    class SuckerPunchAdapter\r\n      class << self\r\n        def enqueue_at(job, timestamp) #:nodoc:\r\n          time = java.util.Date.new(timestamp * 1000)\r\n          timer = JTimer.new(job.to_s)\r\n          timer_task = TimerTask.new\r\n          timer_task.set_runnable(->{JobWrapper.new.async.perform job.serialize })\r\n          timer.java_send(:schedule,[JTimerTask.java_class, java.util.Date.java_class],timer_task, time)\r\n        end\r\n      end\r\n    end\r\n  end\r\nend\r\n\r\n```\r\n\r\nSyntax like:\r\n```\r\nArtifactDownloadJob.set(wait_until: 5.seconds.from_now).perform_later\r\n```\r\nworks in JRuby.\r\n\r\nCris\r\n"},"comment":{"url":"https://api.github.com/repos/brandonhilkert/sucker_punch/issues/comments/233978498","html_url":"https://github.com/brandonhilkert/sucker_punch/issues/172#issuecomment-233978498","issue_url":"https://api.github.com/repos/brandonhilkert/sucker_punch/issues/172","id":233978498,"user":{"login":"cshupp1","id":5719570,"avatar_url":"https://avatars.githubusercontent.com/u/5719570?v=3","gravatar_id":"","url":"https://api.github.com/users/cshupp1","html_url":"https://github.com/cshupp1","followers_url":"https://api.github.com/users/cshupp1/followers","following_url":"https://api.github.com/users/cshupp1/following{/other_user}","gists_url":"https://api.github.com/users/cshupp1/gists{/gist_id}","starred_url":"https://api.github.com/users/cshupp1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cshupp1/subscriptions","organizations_url":"https://api.github.com/users/cshupp1/orgs","repos_url":"https://api.github.com/users/cshupp1/repos","events_url":"https://api.github.com/users/cshupp1/events{/privacy}","received_events_url":"https://api.github.com/users/cshupp1/received_events","type":"User","site_admin":false},"created_at":"2016-07-20T15:06:51Z","updated_at":"2016-07-20T15:06:51Z","body":"This impl leaks.  Please see this updated impl if you are using this lib in JRuby:\r\n\r\nhttps://github.com/brandonhilkert/sucker_punch/issues/181\r\n"}}
{"actor":{"display_login":"cshupp1"}}