lib/bolt/fiber_executor.rb
# Creates a new Puppet scope from the current Plan scope so that variables
# can be used inside the block and won't interact with the outer scope.
# Then creates a new Fiber to execute the block, wraps the Fiber in a
# Bolt::PlanFuture, and returns the Bolt::PlanFuture.
#
Creates a new Puppet scope from the current Plan scope so that variables
can be used inside the block and won't interact with the outer scope.
Then creates a new Fiber to execute the block, wraps the Fiber in a
Bolt::PlanFuture, and returns the Bolt::PlanFuture.
Creates a new Puppet scope from the current Plan scope so that variables can be used inside the block and won ' t interact with the outer scope . Then creates a new Fiber to execute the block wraps the Fiber in a Bolt :: PlanFuture and returns the Bolt :: PlanFuture .
def create_future(plan_id:, scope: nil, name: nil)
      newscope = nil
      if scope
        newscope = Puppet::Parser::Scope.new(scope.compiler)
        local = Puppet::Parser::Scope::LocalScope.new
        scope.to_hash(true, true).each_pair { |k, v| local[k] = v }
        newscope.push_ephemerals([local])
      end
      future = Fiber.new do
        yield newscope
      end
      @id += 1
      future = Bolt::PlanFuture.new(future, @id, name: name, plan_id: plan_id, scope: newscope)
      @logger.trace("Created future #{future.name}")
      active_futures << future
      future
    end
def create_future ( plan_id : , scope : nil , name : nil ) newscope = nil if scope newscope = Puppet :: Parser :: Scope . new ( scope . compiler ) local = Puppet :: Parser :: Scope :: LocalScope . new scope . to_hash ( true , true ) . each_pair { | k , v | local [ k ] = v } newscope . push_ephemerals ( [ local ] ) end future = Fiber . new do yield newscope end @id += 1 future = Bolt :: PlanFuture . new ( future , @id , name : name , plan_id : plan_id , scope : newscope ) @logger . trace ( "Created future #{future.name}" ) active_futures << future future end
Creates a new Puppet scope from the current Plan scope so that variables
can be used inside the block and won't interact with the outer scope.
Creates a new Puppet scope from the current Plan scope so that variables can be used inside the block and won ' t interact with the outer scope .
# Save existing variables to the new scope before starting the future # itself so that if the plan returns before the backgrounded block # starts, we still have the variables. # Compress the current scopes into a single vars hash to add to the new scope # Create a new Fiber that will execute the provided block. # Yield the new scope - this should be ignored by the block if # `newscope` is nil. # PlanFutures are assigned an ID, which is just a global incrementing # integer. The main plan should always have ID 0. They also have a # plan_id, which identifies which plan spawned them. This is used for # tracking which Futures to wait on when `wait()` is called without # arguments. # Register the PlanFuture with the FiberExecutor to be executed
plan_id
<not_specific>
scope
<not_specific>
name
<not_specific>