Class: CircleCI::Parallel::Configuration::MasterNodeConfiguration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMasterNodeConfiguration

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of MasterNodeConfiguration.



11
12
13
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 11

def initialize
  @before_sync_hook = @before_download_hook = @after_download_hook = @after_sync_hook = Hook.new
end

Instance Attribute Details

#after_download_hookObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 8

def after_download_hook
  @after_download_hook
end

#after_sync_hookObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 8

def after_sync_hook
  @after_sync_hook
end

#before_download_hookObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 8

def before_download_hook
  @before_download_hook
end

#before_sync_hookObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 8

def before_sync_hook
  @before_sync_hook
end

Instance Method Details

#after_download(chdir: true) {|download_data_dir| ... }

This method returns an undefined value.

Defines a callback that will be invoked on the master node after downloading all data from slave nodes.

Examples:

CircleCI::Parallel.configure do |config|
  config.on_master_node.after_download do
    merged_data = Dir['*/data.json'].each_with_object({}) do |path, merged_data|
      data = JSON.parse(File.read(path))
      node_name = File.dirname(path)
      merged_data[node_name] = data
    end

    File.write('merged_data.json', JSON.generate(merged_data))
  end
end

Parameters:

  • chdir (Boolean) (defaults to: true)

    whether the callback should be invoked while changing the current working directory to the download data directory.

Yield Parameters:

  • download_data_dir (String)

    the path to the download data directory

See Also:



75
76
77
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 75

def after_download(chdir: true, &block)
  @after_download_hook = Hook.new(block, chdir)
end

#after_sync(chdir: true) {|local_data_dir| ... }

This method returns an undefined value.

Defines a callback that will be invoked on the master node after syncing all nodes.

Examples:

CircleCI::Parallel.configure do |config|
  config.on_master_node.after_sync do
    clean_some_intermediate_data
  end
end

Parameters:

  • chdir (Boolean) (defaults to: true)

    whether the callback should be invoked while changing the current working directory to the local data directory.

Yield Parameters:

  • local_data_dir (String)

    the path to the local data directory

See Also:



96
97
98
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 96

def after_sync(chdir: true, &block)
  @after_sync_hook = Hook.new(block, chdir)
end

#before_download(chdir: true) {|download_data_dir| ... }

This method returns an undefined value.

Defines a callback that will be invoked on the master node before downloading all data from slave nodes.

Parameters:

  • chdir (Boolean) (defaults to: true)

    whether the callback should be invoked while changing the current working directory to the download data directory.

Yield Parameters:

  • download_data_dir (String)

    the path to the download data directory

See Also:



47
48
49
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 47

def before_download(chdir: true, &block)
  @before_download_hook = Hook.new(block, chdir)
end

#before_sync(chdir: true) {|local_data_dir| ... }

This method returns an undefined value.

Defines a callback that will be invoked on the master node before syncing all nodes.

Examples:

CircleCI::Parallel.configure do |config|
  config.on_master_node.before_sync do
    File.write('data.json', JSON.generate(some_data))
  end
end

Parameters:

  • chdir (Boolean) (defaults to: true)

    whether the callback should be invoked while changing the current working directory to the local data directory.

Yield Parameters:

  • local_data_dir (String)

    the path to the local data directory

See Also:



32
33
34
# File 'lib/circleci/parallel/configuration/master_node_configuration.rb', line 32

def before_sync(chdir: true, &block)
  @before_sync_hook = Hook.new(block, chdir)
end