Class: Qtrix::Matrix::RowBuilder
- Inherits:
-
Object
- Object
- Qtrix::Matrix::RowBuilder
- Includes:
- Common, Namespacing
- Defined in:
- lib/qtrix/matrix/row_builder.rb
Overview
Carries out the construction of rows within the matrix for a number of workers for a specific hostname.
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#all_entries ⇒ Object
readonly
Returns the value of attribute all_entries.
-
#desired_distribution ⇒ Object
readonly
Returns the value of attribute desired_distribution.
-
#heads ⇒ Object
readonly
Returns the value of attribute heads.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#matrix ⇒ Object
readonly
Returns the value of attribute matrix.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(*args) ⇒ RowBuilder
constructor
A new instance of RowBuilder.
Methods included from Common
Methods included from Namespacing
#extract_args, included, #redis, #redis_namespace
Constructor Details
#initialize(*args) ⇒ RowBuilder
Returns a new instance of RowBuilder.
15 16 17 18 19 20 21 |
# File 'lib/qtrix/matrix/row_builder.rb', line 15 def initialize(*args) @namespace, @hostname, @workers = extract_args(2, *args) @matrix = Qtrix::Matrix.fetch(namespace) @desired_distribution = Qtrix.desired_distribution(namespace) @heads = matrix.map{|row| row.entries.first.queue} @all_entries = matrix.map(&:entries).flatten end |
Instance Attribute Details
#all_entries ⇒ Object (readonly)
Returns the value of attribute all_entries.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def all_entries @all_entries end |
#desired_distribution ⇒ Object (readonly)
Returns the value of attribute desired_distribution.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def desired_distribution @desired_distribution end |
#heads ⇒ Object (readonly)
Returns the value of attribute heads.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def heads @heads end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def hostname @hostname end |
#matrix ⇒ Object (readonly)
Returns the value of attribute matrix.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def matrix @matrix end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def namespace @namespace end |
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
12 13 14 |
# File 'lib/qtrix/matrix/row_builder.rb', line 12 def workers @workers end |
Instance Method Details
#build ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/qtrix/matrix/row_builder.rb', line 23 def build [].tap do |result| (1..workers).each do queues_for_row = queue_prioritizer.current_priority_queue build_row_for! hostname, queues_for_row result << queues_for_row.map(&:name) end end end |