Module: ParallelWorkforce::Job::Util::JobHelper::ClassMethods

Defined in:
lib/parallel_workforce/job/util/job_helper.rb

Instance Method Summary collapse

Instance Method Details

#build_serialized_actor_args_key(result_key, index) ⇒ Object



10
11
12
# File 'lib/parallel_workforce/job/util/job_helper.rb', line 10

def build_serialized_actor_args_key(result_key, index)
  "#{result_key}:#{index}:serialized-actor-args"
end

#enqueue_actor_job(enqueue_method, **kwargs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/parallel_workforce/job/util/job_helper.rb', line 14

def enqueue_actor_job(enqueue_method, **kwargs)
  serialized_actor_args = kwargs.delete(:serialized_actor_args)

  ::ParallelWorkforce.configuration.redis_connector.with do |redis|
    redis.setex(
      build_serialized_actor_args_key(kwargs[:result_key], kwargs[:index]),
      ::ParallelWorkforce.configuration.job_key_expiration,
      serialized_actor_args,
    )
  end

  send(
    enqueue_method,
    **kwargs,
  )
end