module Dynamiq::Worker::ClassMethods

Public Instance Methods

perform_async(score, *args) click to toggle source
# File lib/dynamiq/worker.rb, line 16
def perform_async(score, *args)
  client_push score: score, class: self, args: args
end
perform_at(interval, score, *args)
Alias for: perform_in
perform_in(interval, score, *args) click to toggle source
# File lib/dynamiq/worker.rb, line 20
def perform_in(interval, score, *args)
  int = interval.to_f
  now = Time.now.to_f
  ts = (int < 1_000_000_000 ? now + int : int)

  item = { score: score, class: self, args: args, at: ts }

  # Optimization to enqueue something now that is scheduled to go out now or in the past
  item.delete 'at' if ts <= now

  client_push item
end
Also aliased as: perform_at