lib/litejob.rb in litejob-0.2.1 vs lib/litejob.rb in litejob-0.2.2

- old
+ new

@@ -1,53 +1,28 @@ # frozen_string_literal: true require_relative "litejob/version" -require_relative "litejob/client" +require_relative "litejob/concern" require_relative "litejob/server" +require "logger" -# Litejob is responsible for providing an interface to job classes module Litejob def self.included(klass) - klass.extend(ClassMethods) + klass.extend(Concern) 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 + + Configuration = Struct.new(:logger) + + def self.configuration + @configuration ||= Configuration.new( + _logger = Logger.new($stdout), + ) + end + + def self.configure + yield(configuration) + end + + def self.logger + configuration.logger end end