Permalink
Browse files

Unsuring arguments can be serialized/deserialized on dbs other than m…

…ysql

- Base64 encoding/decoding arguments
- modifying args column to be stored as text

Signed-off-by: Hemant Kumar <gethemant@gmail.com>
  • Loading branch information...
1 parent dbd299c commit ad26f5d9496004b964a635c3b8c1539e6ef6949b @swindsor swindsor committed with Mar 27, 2009
@@ -1,7 +1,7 @@
class <%= class_name %> < ActiveRecord::Migration
def self.up
create_table :<%= bdrb_table_name %> do |t|
- t.column :args, :binary
+ t.column :args, :text
t.column :worker_name, :string
t.column :worker_method, :string
t.column :job_key, :string
@@ -30,7 +30,7 @@ def method_missing(method_id,*args)
elsif worker_method =~ /^enq_(\w+)/i
raise NoJobKey.new("Must specify a job key with enqueued tasks") if job_key.blank?
method_name = $1
- marshalled_args = Marshal.dump(arg)
+ marshalled_args = Base64.encode64(Marshal.dump(arg))
enqueue_task(compact(:worker_name => worker_name.to_s,:worker_key => worker_key.to_s,
:worker_method => method_name.to_s,:job_key => job_key.to_s, :priority => priority,
:args => marshalled_args,:timeout => arguments ? arguments[:timeout] : nil,:scheduled_at => new_schedule))
@@ -337,7 +337,7 @@ def check_for_enqueued_tasks
if self.respond_to? task.worker_method
Thread.current[:persistent_job_id] = task[:id]
Thread.current[:job_key] = task[:job_key]
- args = load_data(task.args)
+ args = Marshal.load(Base64.decode64(task.args))
invoke_user_method(task.worker_method,args)
else
task.release_job

0 comments on commit ad26f5d

Please sign in to comment.