Class: CircleCI::Parallel::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/circleci/parallel/node.rb

Overview

Represents a CircleCI node.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(build, index) ⇒ 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

#buildObject (readonly)

Returns the value of attribute build.



5
6
7
# File 'lib/circleci/parallel/node.rb', line 5

def build
  @build
end

#indexObject (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_dirString

Returns the local data directory where node specific data should be saved in.



40
41
42
# File 'lib/circleci/parallel/node.rb', line 40

def data_dir
  File.join(BASE_DATA_DIR, ssh_host)
end

#hashObject



20
21
22
# File 'lib/circleci/parallel/node.rb', line 20

def hash
  build.hash ^ index.hash
end

#master?Boolean



25
26
27
# File 'lib/circleci/parallel/node.rb', line 25

def master?
  index.zero?
end

#other_nodesArray<Node>



45
46
47
# File 'lib/circleci/parallel/node.rb', line 45

def other_nodes
  @other_nodes ||= (build.nodes - [self]).freeze
end

#ssh_hostString Also known as: name



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