Class: Agent::Lock::CLI::Commands::Acquire

Inherits:
TreeCommand
  • Object
show all
Defined in:
lib/agent/lock/cli/commands/acquire.rb

Overview

Claim a scope, or find out who has it.

Instance Attribute Summary

Attributes inherited from Base

#launcher

Instance Method Summary collapse

Methods inherited from TreeCommand

inherited

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Agent::Lock::CLI::Commands::Base

Instance Method Details

#call(scope:, intent: nil, **options) ⇒ Manager::Result

Parameters:

  • scope (String) —

    as typed: a path, a directory or a glob

  • intent (String, nil) (defaults to: nil) —

    what the holder is about to do

  • options (Hash) —

    :dir, :locking_strategy, :redis_url, :enforce, :allow_wide

Returns:



31
32
33
34
35
36
37
38
39
40
# File 'lib/agent/lock/cli/commands/acquire.rb', line 31

def call(scope:, intent: nil, **options)
  manager = manager(options)
  result = manager.acquire(
    scope, intent: intent || "unspecified",
           enforce: options[:enforce], wide: options[:allow_wide]
  )

  report(result, manager.stale_minutes)
  finish(result)
end