Class: Yobi::CancellableProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/yobi/cancellable_proxy.rb,
sig/yobi.rbs

Overview

Returned by Repository#with_cancellation. Exposes only the six long-running methods a Yobi::Cancellation token can stop; every other Repository method (#snapshots, #mount, #init, ...) is unreachable here.

token reaches the repository via a thread-local, set only for the duration of each call and only on the calling thread.

Instance Method Summary collapse

Constructor Details

#initialize(repository, token) ⇒ CancellableProxy



9
10
11
12
# File 'lib/yobi/cancellable_proxy.rb', line 9

def initialize(repository, token)
  @repository = repository
  @token = token
end

Instance Method Details

#backupObject



14
15
16
# File 'lib/yobi/cancellable_proxy.rb', line 14

def backup(...)
  with_token { @repository.backup(...) }
end

#checkObject



22
23
24
# File 'lib/yobi/cancellable_proxy.rb', line 22

def check(...)
  with_token { @repository.check(...) }
end

#copyObject



34
35
36
# File 'lib/yobi/cancellable_proxy.rb', line 34

def copy(...)
  with_token { @repository.copy(...) }
end

#forgetObject



30
31
32
# File 'lib/yobi/cancellable_proxy.rb', line 30

def forget(...)
  with_token { @repository.forget(...) }
end

#pruneObject



26
27
28
# File 'lib/yobi/cancellable_proxy.rb', line 26

def prune(...)
  with_token { @repository.prune(...) }
end

#restoreObject



18
19
20
# File 'lib/yobi/cancellable_proxy.rb', line 18

def restore(...)
  with_token { @repository.restore(...) }
end