Class: ElasticBeans::ConfigurationTemplate::Worker

Inherits:
Base show all
Defined in:
lib/elastic_beans/configuration_template/worker.rb

Overview

The worker configuration templates stored in the Elastic Beanstalk application. Settings for the worker environments are stored here. This class is used to construct multiple worker configuration templates, one per queue.

Constant Summary

Constants inherited from ElasticBeans::ConfigurationTemplate

SOLUTION_STACK_PATTERN, SOURCE_CONFIGURATION, WORKER_TEMPLATE_NAME_PATTERN

Instance Attribute Summary collapse

Attributes inherited from ElasticBeans::ConfigurationTemplate

#name

Instance Method Summary collapse

Methods inherited from Base

#solution_stack_name

Methods inherited from ElasticBeans::ConfigurationTemplate

new_by_type, new_from_existing, #option_settings, #options_to_remove, #solution_stack_name, #upsert

Constructor Details

#initialize(queue:, **args) ⇒ Worker

Returns a new instance of Worker.



9
10
11
12
# File 'lib/elastic_beans/configuration_template/worker.rb', line 9

def initialize(queue:, **args)
  @queue = queue
  super(name: "worker-#{queue}", **args)
end

Instance Attribute Details

#queueObject (readonly)

Returns the value of attribute queue.



7
8
9
# File 'lib/elastic_beans/configuration_template/worker.rb', line 7

def queue
  @queue
end

Instance Method Details

#environmentObject

Fetches the running worker environment using the same queue from the application.



15
16
17
18
19
20
# File 'lib/elastic_beans/configuration_template/worker.rb', line 15

def environment
  if defined? @environment
    return @environment
  end
  @environment = application.environments.find { |environment| environment.is_a?(Environment::Worker) && environment.queue == queue }
end