Class: CircleCI::Parallel::Node
- Inherits:
-
Object
- Object
- CircleCI::Parallel::Node
- Defined in:
- lib/circleci/parallel/node.rb
Overview
Represents a CircleCI node.
Instance Attribute Summary collapse
-
#build ⇒ Object
readonly
Returns the value of attribute build.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#data_dir ⇒ String
The local data directory where node specific data should be saved in.
- #hash ⇒ Object
-
#initialize(build, index) ⇒ Node
constructor
A new instance of Node.
-
#master? ⇒ Boolean
Whether the node is the master node or not.
-
#other_nodes ⇒ Array<Node>
Other nodes of the same build.
-
#ssh_host ⇒ String
The hostname that can be used for
ssh
command to connect between nodes.
Constructor Details
#initialize(build, index) ⇒ Node
Returns a new instance of Node.
9 10 11 12 |
# File 'lib/circleci/parallel/node.rb', line 9 def initialize(build, index) @build = build @index = index end |
Instance Attribute Details
#build ⇒ Object (readonly)
Returns the value of attribute build.
5 6 7 |
# File 'lib/circleci/parallel/node.rb', line 5 def build @build end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
5 6 7 |
# File 'lib/circleci/parallel/node.rb', line 5 def index @index end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
14 15 16 |
# File 'lib/circleci/parallel/node.rb', line 14 def ==(other) build == other.build && index == other.index end |
#data_dir ⇒ String
Returns the local data directory where node specific data should be saved in.
38 39 40 |
# File 'lib/circleci/parallel/node.rb', line 38 def data_dir File.join(BASE_DATA_DIR, ssh_host) end |
#hash ⇒ Object
20 21 22 |
# File 'lib/circleci/parallel/node.rb', line 20 def hash build.hash ^ index.hash end |
#master? ⇒ Boolean
Returns whether the node is the master node or not.
25 26 27 |
# File 'lib/circleci/parallel/node.rb', line 25 def master? index.zero? end |
#other_nodes ⇒ Array<Node>
Returns other nodes of the same build.
43 44 45 |
# File 'lib/circleci/parallel/node.rb', line 43 def other_nodes @other_nodes ||= (build.nodes - [self]).freeze end |
#ssh_host ⇒ String
Returns the hostname that can be used for ssh
command to connect between nodes.
30 31 32 33 |
# File 'lib/circleci/parallel/node.rb', line 30 def ssh_host # https://circleci.com/docs/ssh-between-build-containers/ "node#{index}" end |