Class: Agent::Lock::CLI::Commands::Break

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

Overview

Take a lock away from whoever holds it.

Deliberately blunt and deliberately loud: an expired lock is reaped on its own, so reaching for this means overruling a holder that still looks alive. Whoever runs it owns the consequence.

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:, **options) ⇒ Manager::Result

Returns :broken or :not_found.

Parameters:

  • scope (String)
  • options (Hash) —

    :dir, :locking_strategy, :redis_url

Returns:



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/agent/lock/cli/commands/break.rb', line 24

def call(scope:, **options)
  result = manager(options).break_lock(scope)

  if result.status == :not_found
    say("NOT LOCKED #{scope}")
  else
    warn_("BREAKING #{scope_of(result.record)}, held by #{holder_of(result.record)}")
    warn_("  intent: #{printable(result.record.intent, lines: true)}") unless result.record.intent.empty?
    say("Broken. You are responsible for having announced this first.")
  end

  finish(result)
end