module Antelopes
Nice and smart background jobs.
@since 0.0.1
Public Class Methods
configuration()
click to toggle source
Loopers configuration to pass to ServerEngine
@since 0.0.1 @todo Make it configurable via a configuration file or environment variables
# File lib/antelopes.rb, line 46 def self.configuration Hash[ worker_type: 'thread', workers: 4, supervisor: true, enable_detach: true, log: 'myserver.log', pid_path: 'myserver.pid' ] end
push(job_class, method: nil, class_method: nil, args: Hash[])
click to toggle source
Method to add a job to queue.
@example Instance method call
Antelopes.push('MyClass', method: :call, args: Hash[foo: 'bar']) # The worker will run the following code: MyClass.new.call(foo: 'bar')
@example Class method call
Antelopes.push('MyClass', class_method: :call, args: Hash[foo: 'bar']) # The worker will run the following code: MyClass.call(foo: 'bar')
@param job_class [String] class of the job to perform @param method [Symbol] public method of the instance to call @param class_method [Symbol] public method of the class to call @param args [Hash] parameters for the method
@since 0.0.1
# File lib/antelopes.rb, line 38 def self.push(job_class, method: nil, class_method: nil, args: Hash[]) Pusher.new.call(class: job_class, method: method, class_method: class_method, args: args) end
start()
click to toggle source
Method to call to start the workers
@since 0.0.1
# File lib/antelopes.rb, line 16 def self.start ::ServerEngine.create(Master, Looper, configuration).run end