Module: Marj
- Defined in:
 - lib/marj.rb,
lib/marj/record.rb 
Overview
A minimal database-backed ActiveJob queueing backend.
The Marj module provides the following methods:
- 
query- Queries enqueued jobs - 
discard- Discards a job 
It is possible to call the above methods on the Marj module itself or on any class which includes it.
Example usage:
Marj.query(:first) # Returns the first job
Marj.discard(job)  # Discards the specified job
class ApplicationJob < ActiveJob::Base
  include Marj
end
class SomeJob < ApplicationJob;
  def perform; end
end
job = ApplicationJob.query(:first) # Returns the first enqueued job
job = SomeJob.query(:first)        # Returns the first enqueued job with job_class SomeJob
ApplicationJob.discard(job)        # Discards the specified job
job.discard                        # Discards the job
  Defined Under Namespace
Modules: ClassMethods Classes: Record
Constant Summary collapse
- VERSION =
          
The Marj version.
 '5.0.0'
Class Method Summary collapse
- 
  
    
      .discard(job)  ⇒ ActiveJob::Base 
    
    
  
  
  
  
  
  
  
  
  
    
Discards the specified job.
 - 
  
    
      .query(*args, **kwargs)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Queries enqueued jobs.
 
Instance Method Summary collapse
- 
  
    
      #discard  ⇒ ActiveJob::Base 
    
    
  
  
  
  
  
  
  
  
  
    
Discards this job.
 
Class Method Details
.discard(job) ⇒ ActiveJob::Base
Discards the specified job.
      74 75 76  | 
    
      # File 'lib/marj.rb', line 74 def self.discard(job) queue_adapter.discard(job) end  | 
  
.query(*args, **kwargs) ⇒ Object
Queries enqueued jobs.
Similar to ActiveRecord.where with a few additional features.
Example usage:
query(:all)             # Delegates to Marj::Record.all
query(:due)             # Delegates to Marj::Record.due
query(:all, limit: 10)  # Returns a maximum of 10 jobs
query(job_class: Foo)   # Returns all jobs with job_class Foo
query('123')            # Returns the job with id '123' or nil if no such job exists
query(id: '123')        # Same as above
query(job_id: '123')    # Same as above
query(queue: 'foo')     # Returns all jobs in the 'foo' queue
query(job_queue: 'foo') # Same as above
  
      69 70 71  | 
    
      # File 'lib/marj.rb', line 69 def self.query(*args, **kwargs) queue_adapter.query(*args, **kwargs) end  | 
  
Instance Method Details
#discard ⇒ ActiveJob::Base
Discards this job.
      81 82 83  | 
    
      # File 'lib/marj.rb', line 81 def discard self.class.queue_adapter.discard(self) end  |