Class: CircleCI::Parallel::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
# File 'lib/circleci/parallel/configuration.rb', line 12

def initialize
  @silent = false
  @before_join_hook = @after_join_hook = @after_download_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.



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

def after_download_hook
  @after_download_hook
end

#after_join_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.



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

def after_join_hook
  @after_join_hook
end

#before_join_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.



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

def before_join_hook
  @before_join_hook
end

#silentBoolean

Returns whether progress messages should be outputted to STDOUT (default: false).

Returns:

  • (Boolean)

    whether progress messages should be outputted to STDOUT (default: false)



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

def silent
  @silent
end

Instance Method Details

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

This method returns an undefined value.

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

Examples:

CircleCI::Parallel.configure do |config|
  config.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 chaging the current working directory to the download data directory.

Yield Parameters:

  • download_data_dir (String)

    the path to the download data directory

See Also:



83
84
85
# File 'lib/circleci/parallel/configuration.rb', line 83

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

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

This method returns an undefined value.

Defines a callback that will be invoked on all nodes after joining nodes.

Examples:

CircleCI::Parallel.configure do |config|
  config.after_join do
    clean_some_intermediate_data
  end
end

Parameters:

  • chdir (Boolean) (defaults to: true)

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

Yield Parameters:

  • local_data_dir (String)

    the path to the local data directory

See Also:



55
56
57
# File 'lib/circleci/parallel/configuration.rb', line 55

def after_join(chdir: true, &block)
  @after_join_hook = Hook.new(block, chdir)
end

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

This method returns an undefined value.

Defines a callback that will be invoked on all nodes before joining nodes.

Examples:

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

Parameters:

  • chdir (Boolean) (defaults to: true)

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

Yield Parameters:

  • local_data_dir (String)

    the path to the local data directory

See Also:



34
35
36
# File 'lib/circleci/parallel/configuration.rb', line 34

def before_join(chdir: true, &block)
  @before_join_hook = Hook.new(block, chdir)
end