Class: Kitchen::Plugin::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/kitchen/plugin_base.rb

Overview

Common base class for every plugin type (Driver, Provisioner, Transport, and Verifier), providing the shared plugin lifecycle and the serial-action registry.

Author:

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.serial_actionsArray<Symbol> (readonly)

Returns an array of action method names that cannot be run concurrently and must be run in serial via a shared mutex.

Returns:

  • (Array<Symbol>)

    an array of action method names that cannot be run concurrently and must be run in serial via a shared mutex



29
30
31
# File 'lib/kitchen/plugin_base.rb', line 29

def serial_actions
  @serial_actions
end

Class Method Details

.no_parallel_for(*methods) ⇒ Object

Registers certain driver actions that cannot be safely run concurrently in threads across multiple instances. Typically this might be used for create or destroy actions that use an underlying resource that cannot be used at the same time.

A shared mutex for this driver object will be used to synchronize all registered methods.

Examples:

a single action method that cannot be run concurrently


no_parallel_for :create

multiple action methods that cannot be run concurrently


no_parallel_for :create, :destroy

Parameters:

  • methods (Array<Symbol>)

    one or more actions as symbols

Raises:

  • (ClientError)

    if any method is not a valid action method name



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kitchen/plugin_base.rb', line 50

def self.no_parallel_for(*methods)
  action_methods = %i{create setup converge verify destroy}

  Array(methods).each do |meth|
    next if action_methods.include?(meth)

    raise ClientError, "##{meth} is not a valid no_parallel_for method"
  end

  @serial_actions ||= []
  @serial_actions += methods
end