Class: PassiveQueue::Adapter

Inherits:
Object
  • Object
show all
Defined in:
lib/passive_queue/adapter.rb

Overview

ActiveJob queue adapter that accepts jobs but never processes them. Implements the ActiveJob adapter interface with zen-like non-execution.

Instance Method Summary collapse

Constructor Details

#initializeAdapter

Initializes a new Adapter instance with the zen of doing nothing



6
7
8
# File 'lib/passive_queue/adapter.rb', line 6

def initialize
  # Initialize with the zen of doing nothing
end

Instance Method Details

#enqueue(job) ⇒ void

This method returns an undefined value.

Enqueues a job for immediate non-execution

Parameters:

  • job (ActiveJob::Base)

    the job to passively accept



14
15
16
# File 'lib/passive_queue/adapter.rb', line 14

def enqueue(job)
  log_job_acceptance(job)
end

#enqueue_all(jobs) ⇒ Array<void>

Enqueues multiple jobs for batch non-execution

Parameters:

  • jobs (Array<ActiveJob::Base>)

    array of jobs to passively accept

Returns:

  • (Array<void>)

    results of enqueueing each job



31
32
33
# File 'lib/passive_queue/adapter.rb', line 31

def enqueue_all(jobs)
  jobs.map { |job| enqueue(job) }
end

#enqueue_at(job, timestamp) ⇒ void

This method returns an undefined value.

Enqueues a job for delayed non-execution at a specific time

Parameters:

  • job (ActiveJob::Base)

    the job to schedule for non-execution

  • timestamp (Numeric)

    Unix timestamp when the job should not be executed



23
24
25
# File 'lib/passive_queue/adapter.rb', line 23

def enqueue_at(job, timestamp)
  log_job_scheduling(job, timestamp)
end

#stopping?Boolean

Returns whether the adapter is stopping (always true for zen purposes)

Returns:

  • (Boolean)

    always returns true to maintain peaceful state



38
39
40
# File 'lib/passive_queue/adapter.rb', line 38

def stopping?
  true
end