Class: ActiveJob::QueueAdapters::KubernetesAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/kubernetes_adapter.rb

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/active_job/queue_adapters/kubernetes_adapter.rb', line 8

def enqueue(job)
  serialized_job = JSON.dump(job.serialize)
  kube_job = Kubeclient::Resource.new(job.manifest)

  kube_job.spec.template.spec.containers.map do |container|
    container.env ||= []
    container.env.push({
      'name' => 'SERIALIZED_JOB',
      'value' => serialized_job
    })
  end

  job.kubeclient('/apis/batch').create_job(kube_job)
end

#enqueue_at(_job, _timestamp) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/active_job/queue_adapters/kubernetes_adapter.rb', line 23

def enqueue_at(_job, _timestamp)
  raise NotImplementedError, 'Enqueueing jobs in the future is not supported.'
end