Class: Agent::Lock::CLI::Commands::SwitchBackend
- Defined in:
- lib/agent/lock/cli/commands/switch_backend.rb
Overview
Move a checkout's locks to the other backend.
The backend marker binds a checkout to the store it used first, so that two agents beside each other never use two stores. Releasing every lock did not move it, so the one way out used to be deleting the marker by hand. This is that, done safely.
A Base, not a TreeCommand: the backend is the argument, so a
--locking-strategy beside it would be a second answer to the same
question.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#call(backend:, **options) ⇒ Manager::Result?
Nil when the tree was bound to nothing yet, or to a Redis that does not answer.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Agent::Lock::CLI::Commands::Base
Instance Method Details
#call(backend:, **options) ⇒ Manager::Result?
Returns nil when the tree was bound to nothing yet, or to a Redis that does not answer.
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/agent/lock/cli/commands/switch_backend.rb', line 39 def call(backend:, **) tree = Tree.for([:dir] || ".") target = target_store(tree, backend, [:redis_url]) current, unread = current_store(tree) return leave_unread(tree, target, unread, ) if unread return bind_virgin(tree, target) if current.nil? result = Manager.new(tree: tree, store: current).switch_backend(target, discard: [:discard_locks]) report(result, from: current.backend, to: target.backend, url: [:redis_url]) finish(result) end |