litebackup 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4eb191611d126c2acb397b1278ed76e6504113b310369eb4eb7e9d396f64662
4
- data.tar.gz: cd8ba487c55823345828bcd1cd1e19dbab033354bce7efe13d355a1e583e42aa
3
+ metadata.gz: 6258e984fe35b38af2a8c2c75a9729bd5e705a6fd2de51ea0eb055b74135e383
4
+ data.tar.gz: 6fac885cd86ea415e901d950b8dbdf19b32c4975a7801f5aaa8da6dc02360541
5
5
  SHA512:
6
- metadata.gz: 01a4d431da158be32fb2ab440645aa4c3d6b918172ee67f24794ac51abe3eebf6ecb2ac04832971121ac49dda6b0e496443698640f2ab7d07a68fac880a3f35c
7
- data.tar.gz: 52ec52020b0ab5aef109d0afb826a69cafd849ec87f8e628e15fd53cbe5dc688d44dd8e24d016091583b438944902436525ca71486ffcd9df8af1509e26a98f5
6
+ metadata.gz: 37a108073a58bd24d2177c6adcc46d55f446d17b912eef207ce66c52a00d935589b132dd432e60796c4eb10ab4fa611d54be7b58aaa33adb0b1cceac3c926947
7
+ data.tar.gz: 38b40b410398e77cb4ff934f145cb9e352777464e4e0da4285fdaf7a936a17f696b8a1d1d40f36bee57cc50ed775138c97c90b2fb7496ff907c9d8c1d028303d
@@ -117,7 +117,7 @@ module Litebackup
117
117
  end
118
118
 
119
119
  # Connects, starting the daemon when needed; fails with daemon_unsupported
120
- # for a daemon older than 1.5.0.
120
+ # for a daemon older than 1.6.0.
121
121
  def connect
122
122
  ensure_open
123
123
  @connect_lock.synchronize do
@@ -500,18 +500,18 @@ module Litebackup
500
500
  # Runs the database at path, the same on every machine; returns once this
501
501
  # machine is the origin or has a replica. See Failover for the callbacks:
502
502
  # on_role_change hears the role the start answered, then every change;
503
- # on_refused hears the daemon's message when it refused this machine's
503
+ # on_denied hears the daemon's message when it refused this machine's
504
504
  # file; on_error hears each failed read. A file at the path that differs
505
505
  # from the server head, and is not a clean copy of the version this
506
506
  # machine last synced, is refused with conflict and left untouched;
507
507
  # discard_local replaces it with the head.
508
- def start(path, name: nil, timeout: nil, discard_local: false, on_role_change: nil, on_refused: nil, on_error: nil)
508
+ def start(path, name: nil, timeout: nil, discard_local: false, on_role_change: nil, on_denied: nil, on_error: nil)
509
509
  call = Wire.start_failover(path, name: name, timeout: timeout, discard_local: discard_local)
510
510
  log_end = @client.call(Wire.events_page(after: -1))
511
511
  started = @client.call(call)
512
512
  @client.ensure_open
513
513
  failover = Failover.new(@client, started, log_end.next, on_role_change: on_role_change,
514
- on_refused: on_refused, on_error: on_error)
514
+ on_denied: on_denied, on_error: on_error)
515
515
  @client.add_failover(failover)
516
516
  failover.start_following
517
517
  failover
@@ -23,8 +23,8 @@ module Litebackup
23
23
  EVENT_PAGE = 1000
24
24
  ROLE_CHANGED = Models::EventType::ROLE_CHANGED
25
25
  DRAINING = Models::EventType::DRAINING
26
- REFUSED = Models::EventType::REFUSED
27
- ROLE_EVENT_TYPES = [ROLE_CHANGED, DRAINING, REFUSED].freeze
26
+ DENIED = Models::EventType::DENIED
27
+ ROLE_EVENT_TYPES = [ROLE_CHANGED, DRAINING, DENIED].freeze
28
28
  # Error codes the event reading never retries: they end following. An
29
29
  # expired cursor is not one: a failover resumes at the log's end.
30
30
  FATAL_ERROR_CODES = [
@@ -68,7 +68,7 @@ module Litebackup
68
68
  # What the daemon answered when the failover started.
69
69
  attr_reader :status, :name, :path
70
70
 
71
- def initialize(client, status, cursor, on_role_change: nil, on_refused: nil, on_error: nil)
71
+ def initialize(client, status, cursor, on_role_change: nil, on_denied: nil, on_error: nil)
72
72
  @client = client
73
73
  @status = status
74
74
  @name = status.name
@@ -78,7 +78,7 @@ module Litebackup
78
78
  @event_wait = Failover.event_wait_seconds
79
79
  @confirmation_limit = Failover.confirmation_limit_seconds
80
80
  @on_role_change = on_role_change
81
- @on_refused = on_refused
81
+ @on_denied = on_denied
82
82
  @on_error = on_error
83
83
  @stopped = false
84
84
  @owner_pid = Process.pid
@@ -160,7 +160,7 @@ module Litebackup
160
160
 
161
161
  # The role a status read reports: unknown while the daemon drains the
162
162
  # origin, as after a draining event, and while the failover's file is
163
- # refused (conflicted), as after a refused event.
163
+ # refused (conflicted), as after a denied event.
164
164
  def status_role(database)
165
165
  database.draining == true || database.state == Wire::STATE_CONFLICTED ? UNKNOWN : database.role
166
166
  end
@@ -189,7 +189,7 @@ module Litebackup
189
189
  # An event older than the last role read changes no role, because
190
190
  # that read has it; a refusal among them is still reported.
191
191
  older_than_role_read = role_event?(event.type) && event.id <= progress.role_read_log_end
192
- return if older_than_role_read && event.type != REFUSED
192
+ return if older_than_role_read && event.type != DENIED
193
193
 
194
194
  case event.type
195
195
  when ROLE_CHANGED
@@ -199,12 +199,12 @@ module Litebackup
199
199
  # the lock, so the app stops writing while no machine is allowed to
200
200
  # take over yet.
201
201
  change_role(UNKNOWN)
202
- when REFUSED
202
+ when DENIED
203
203
  # The daemon refused this machine's file and the failover stays
204
204
  # conflicted there: this machine neither writes nor follows the database.
205
205
  change_role(UNKNOWN) unless older_than_role_read
206
206
  # The role callback could have stopped the failover.
207
- @on_refused.call(event.message) if !@stopped && !@on_refused.nil?
207
+ @on_denied.call(event.message) if !@stopped && !@on_denied.nil?
208
208
  end
209
209
  end
210
210
  end
@@ -7,11 +7,12 @@ module Litebackup
7
7
  module Models
8
8
  # What happened to a database: role_changed (role is origin or replica, and message is text),
9
9
  # draining (a failover origin stops being the origin before a drain releases its lock: its role
10
- # is unknown until the next role_changed), refused (path names the refused file, such as a
10
+ # is unknown until the next role_changed), denied (path names the refused file, such as a
11
11
  # failover's file that holds writes the server lacks), path_unreadable (path names the path a
12
12
  # backup rule could not read), and the others by their names.
13
13
  module EventType
14
14
  ACQUIRED = "acquired"
15
+ DENIED = "denied"
15
16
  DOWNLOAD_FINISHED = "download_finished"
16
17
  DOWNLOAD_STARTED = "download_started"
17
18
  DRAINING = "draining"
@@ -21,7 +22,6 @@ module Litebackup
21
22
  OFFLOADED = "offloaded"
22
23
  PATH_UNREADABLE = "path_unreadable"
23
24
  REBASED = "rebased"
24
- REFUSED = "refused"
25
25
  RELEASED = "released"
26
26
  REPLICATING = "replicating"
27
27
  RESTORED = "restored"
@@ -33,6 +33,7 @@ module Litebackup
33
33
  TRACKED = "tracked"
34
34
  ALL = [
35
35
  ACQUIRED,
36
+ DENIED,
36
37
  DOWNLOAD_FINISHED,
37
38
  DOWNLOAD_STARTED,
38
39
  DRAINING,
@@ -42,7 +43,6 @@ module Litebackup
42
43
  OFFLOADED,
43
44
  PATH_UNREADABLE,
44
45
  REBASED,
45
- REFUSED,
46
46
  RELEASED,
47
47
  REPLICATING,
48
48
  RESTORED,
@@ -49,9 +49,9 @@ module Litebackup
49
49
  # JSON: drain_required when the launch refused a new credential for a
50
50
  # client that has write locks, and launch_failed otherwise, also with the
51
51
  # whole output when the command reported no error as JSON.
52
- def launch_refusal(output)
53
- refusal = ""
54
- refusal_code = ErrorCode::LAUNCH_FAILED
52
+ def launch_denial(output)
53
+ denial = ""
54
+ denial_code = ErrorCode::LAUNCH_FAILED
55
55
  output.each_line do |line|
56
56
  diagnostic = begin
57
57
  JSON.parse(line)
@@ -64,17 +64,17 @@ module Litebackup
64
64
  message = diagnostic["message"]
65
65
  next unless message.is_a?(String) && !message.empty?
66
66
 
67
- refusal = message
68
- refusal_code = diagnostic["code"] == ErrorCode::DRAIN_REQUIRED ? ErrorCode::DRAIN_REQUIRED : ErrorCode::LAUNCH_FAILED
67
+ denial = message
68
+ denial_code = diagnostic["code"] == ErrorCode::DRAIN_REQUIRED ? ErrorCode::DRAIN_REQUIRED : ErrorCode::LAUNCH_FAILED
69
69
  end
70
- return [ErrorCode::LAUNCH_FAILED, output.strip] if refusal.empty?
70
+ return [ErrorCode::LAUNCH_FAILED, output.strip] if denial.empty?
71
71
 
72
- [refusal_code, refusal]
72
+ [denial_code, denial]
73
73
  end
74
74
 
75
75
  def launch_failed(output, cause)
76
- code, refusal = launch_refusal(output)
77
- Error.new(code, "starting Litebackup failed: #{refusal.empty? ? cause : refusal}")
76
+ code, denial = launch_denial(output)
77
+ Error.new(code, "starting Litebackup failed: #{denial.empty? ? cause : denial}")
78
78
  end
79
79
 
80
80
  # Starts the session daemon when nothing listens on its socket.
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Litebackup
4
4
  # Sent with every call. Daemons refuse SDKs older than their minimum with sdk_unsupported.
5
- VERSION = "1.5.0"
5
+ VERSION = "1.6.0"
6
6
  # Connecting to an older daemon fails with daemon_unsupported.
7
- MINIMUM_DAEMON_VERSION = "1.5.0"
7
+ MINIMUM_DAEMON_VERSION = "1.6.0"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: litebackup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Litebackup