Sha256: 05b9c8a946c8291021eea8d922623bbc06ec54c8ea045174f1853a456264a611
Contents?: true
Size: 1.18 KB
Versions: 1
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require_relative "litejob/version" require_relative "litejob/client" require_relative "litejob/server" # Litejob is responsible for providing an interface to job classes module Litejob def self.included(klass) klass.extend(ClassMethods) end module ClassMethods def perform_async(*params) @litejob_options ||= {} client.push(name, params, @litejob_options.merge(delay: 0, queue: queue_name)) end def perform_at(time, *params) @litejob_options ||= {} delay = time.to_i - Time.now.to_i client.push(name, params, @litejob_options.merge(delay: delay, queue: queue_name)) end def perform_in(delay, *params) @litejob_options ||= {} client.push(name, params, @litejob_options.merge(delay: delay, queue: queue_name)) end alias_method :perform_after, :perform_in def delete(id) client.delete(id) end def queue_as(queue_name) @queue_name = queue_name.to_s end def litejob_options(options) @litejob_options = options end private def queue_name @queue_name || "default" end def client @client ||= Client.new end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
litejob-0.2.1 | lib/litejob.rb |