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.



15
16
17
18
19
# File 'lib/circleci/parallel/configuration.rb', line 15

def initialize
  @silent = false
  @mock_mode = 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.



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

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.



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

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.



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

def before_join_hook
  @before_join_hook
end

#mock_modeBoolean

Returns whether mock mode is enabled (default: false).

Returns:

  • (Boolean)

    whether mock mode is enabled (default: false)



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

def mock_mode
  @mock_mode
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:



87
88
89
# File 'lib/circleci/parallel/configuration.rb', line 87

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:



59
60
61
# File 'lib/circleci/parallel/configuration.rb', line 59

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:



38
39
40
# File 'lib/circleci/parallel/configuration.rb', line 38

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