litebackup 1.3.0-aarch64-linux-musl
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 +7 -0
- data/LICENSE +21 -0
- data/README.md +109 -0
- data/lib/litebackup/bin/litebackup +4 -0
- data/lib/litebackup/binary.rb +108 -0
- data/lib/litebackup/client.rb +520 -0
- data/lib/litebackup/credential.rb +65 -0
- data/lib/litebackup/errors.rb +132 -0
- data/lib/litebackup/failover.rb +416 -0
- data/lib/litebackup/foreground.rb +185 -0
- data/lib/litebackup/generated/error_codes.rb +38 -0
- data/lib/litebackup/generated/models.rb +724 -0
- data/lib/litebackup/integrations/rails.rb +142 -0
- data/lib/litebackup/integrations/sqlite3.rb +55 -0
- data/lib/litebackup/integrations/sqlite_file.rb +81 -0
- data/lib/litebackup/launch.rb +146 -0
- data/lib/litebackup/paths.rb +86 -0
- data/lib/litebackup/pool.rb +790 -0
- data/lib/litebackup/release.rb +98 -0
- data/lib/litebackup/transport.rb +352 -0
- data/lib/litebackup/umask.rb +53 -0
- data/lib/litebackup/version.rb +8 -0
- data/lib/litebackup/wire.rb +436 -0
- data/lib/litebackup/wire_model.rb +55 -0
- data/lib/litebackup.rb +61 -0
- metadata +66 -0
|
@@ -0,0 +1,724 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Code generated from client-openapi.yaml by scripts/generate. DO NOT EDIT.
|
|
4
|
+
|
|
5
|
+
module Litebackup
|
|
6
|
+
# The socket API's types; Litebackup exports the ones its methods return.
|
|
7
|
+
module Models
|
|
8
|
+
# What happened to a database: role_changed (role is origin or replica, and message is text),
|
|
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
|
|
11
|
+
# failover's file that holds writes the server lacks), path_unreadable (path names the path a
|
|
12
|
+
# backup rule could not read), and the others by their names.
|
|
13
|
+
module EventType
|
|
14
|
+
ACQUIRED = "acquired"
|
|
15
|
+
DOWNLOAD_FINISHED = "download_finished"
|
|
16
|
+
DOWNLOAD_STARTED = "download_started"
|
|
17
|
+
DRAINING = "draining"
|
|
18
|
+
IMAGE_WRITTEN = "image_written"
|
|
19
|
+
LOCAL_WRITE = "local_write"
|
|
20
|
+
LOCK_LOST = "lock_lost"
|
|
21
|
+
OFFLOADED = "offloaded"
|
|
22
|
+
PATH_UNREADABLE = "path_unreadable"
|
|
23
|
+
REBASED = "rebased"
|
|
24
|
+
REFUSED = "refused"
|
|
25
|
+
RELEASED = "released"
|
|
26
|
+
REPLICATING = "replicating"
|
|
27
|
+
RESTORED = "restored"
|
|
28
|
+
REVERTED = "reverted"
|
|
29
|
+
ROLE_CHANGED = "role_changed"
|
|
30
|
+
ROLLBACK_SCAN = "rollback_scan"
|
|
31
|
+
SERVER_GENERATION = "server_generation"
|
|
32
|
+
STOPPED = "stopped"
|
|
33
|
+
TRACKED = "tracked"
|
|
34
|
+
ALL = [
|
|
35
|
+
ACQUIRED,
|
|
36
|
+
DOWNLOAD_FINISHED,
|
|
37
|
+
DOWNLOAD_STARTED,
|
|
38
|
+
DRAINING,
|
|
39
|
+
IMAGE_WRITTEN,
|
|
40
|
+
LOCAL_WRITE,
|
|
41
|
+
LOCK_LOST,
|
|
42
|
+
OFFLOADED,
|
|
43
|
+
PATH_UNREADABLE,
|
|
44
|
+
REBASED,
|
|
45
|
+
REFUSED,
|
|
46
|
+
RELEASED,
|
|
47
|
+
REPLICATING,
|
|
48
|
+
RESTORED,
|
|
49
|
+
REVERTED,
|
|
50
|
+
ROLE_CHANGED,
|
|
51
|
+
ROLLBACK_SCAN,
|
|
52
|
+
SERVER_GENERATION,
|
|
53
|
+
STOPPED,
|
|
54
|
+
TRACKED
|
|
55
|
+
].freeze
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class Event < Data.define(:id, :time, :name, :type, :message, :role, :path)
|
|
59
|
+
extend WireModel
|
|
60
|
+
# role: for role_changed, the new role
|
|
61
|
+
# path: for refused, the refused file; for path_unreadable, the path the rule could not read
|
|
62
|
+
WIRE_FIELDS = {
|
|
63
|
+
id: [:integer, true],
|
|
64
|
+
time: [:time, true],
|
|
65
|
+
name: [:string, false],
|
|
66
|
+
type: [:string, true],
|
|
67
|
+
message: [:string, true],
|
|
68
|
+
role: [:string, false],
|
|
69
|
+
path: [:string, false]
|
|
70
|
+
}.freeze
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# A version the server acknowledged. Clients decide what durability is enough.
|
|
74
|
+
class SyncedState < Data.define(:version, :time)
|
|
75
|
+
extend WireModel
|
|
76
|
+
WIRE_FIELDS = {
|
|
77
|
+
version: [:integer, true],
|
|
78
|
+
time: [:time, false]
|
|
79
|
+
}.freeze
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# The newest version the server reported the primary bucket holds.
|
|
83
|
+
class ArchivedVersion < Data.define(:version, :archived)
|
|
84
|
+
extend WireModel
|
|
85
|
+
# archived: when the server recorded the version as archived
|
|
86
|
+
WIRE_FIELDS = {
|
|
87
|
+
version: [:integer, true],
|
|
88
|
+
archived: [:time, false]
|
|
89
|
+
}.freeze
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# how far a version must reach: server once the server holds it, cloud once the bucket holds it
|
|
93
|
+
# too
|
|
94
|
+
module Durability
|
|
95
|
+
SERVER = "server"
|
|
96
|
+
CLOUD = "cloud"
|
|
97
|
+
ALL = [
|
|
98
|
+
SERVER,
|
|
99
|
+
CLOUD
|
|
100
|
+
].freeze
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
class DatabaseStatus < Data.define(:name, :path, :role, :state, :acquired, :failover, :backup_rule_id, :local_changed, :synced_server, :synced_cloud, :journal_mode, :page_count, :sync_count, :hint_misses, :last_full_scan_reason, :writer_machine_label, :last_error, :last_error_time, :first_unsynced_change_time, :next_retry_time, :draining, :machine_label, :maintenance, :offload_on_release, :offload_durability)
|
|
104
|
+
extend WireModel
|
|
105
|
+
ROLE_ORIGIN = "origin"
|
|
106
|
+
ROLE_REPLICA = "replica"
|
|
107
|
+
STATE_PENDING = "pending"
|
|
108
|
+
STATE_SYNCING = "syncing"
|
|
109
|
+
STATE_RETRYING = "retrying"
|
|
110
|
+
STATE_SYNCED = "synced"
|
|
111
|
+
STATE_WAITING = "waiting"
|
|
112
|
+
STATE_OFFLOADED = "offloaded"
|
|
113
|
+
STATE_STOPPED = "stopped"
|
|
114
|
+
STATE_CONFLICTED = "conflicted"
|
|
115
|
+
STATE_ERROR = "error"
|
|
116
|
+
|
|
117
|
+
# role: origin when this machine writes the database and backs it up; replica for a live
|
|
118
|
+
# readonly copy
|
|
119
|
+
# state: pending while a backup or failover origin holds no write lock, as after a start or a
|
|
120
|
+
# drain, until a sync takes it (a start takes back the lock of each backup a drain left
|
|
121
|
+
# pending while the head is still the version it last synced); syncing while changes stream;
|
|
122
|
+
# retrying while an origin's syncs fail, with last_error saying why and next_retry_time when
|
|
123
|
+
# the next attempt runs; synced when the server holds every change: a backup or failover
|
|
124
|
+
# origin whose last sync landed with no change seen after it, until its next change, or a
|
|
125
|
+
# released database whose last version is on the server; waiting while another machine is the
|
|
126
|
+
# origin; offloaded when the local file was removed because the server, or the bucket when the
|
|
127
|
+
# offload asked for it, holds its last version; stopped for a stopped replica; conflicted when
|
|
128
|
+
# this copy was refused and left as it is, because its file differs from the server head or
|
|
129
|
+
# its write lock was lost or broken; error with last_error
|
|
130
|
+
# acquired: the database is acquired and released by a worker rather than backed up
|
|
131
|
+
# continuously
|
|
132
|
+
# failover: the database belongs to a failover and changes role when the origin does
|
|
133
|
+
# backup_rule_id: the backup or failover rule that tracks the database on this machine; absent
|
|
134
|
+
# for an acquired database and a replica
|
|
135
|
+
# journal_mode: wal, rollback, or unknown before the first scan. A full scan of a
|
|
136
|
+
# rollback-journal database holds a read lock that blocks the app's writers until it ends, so
|
|
137
|
+
# it runs at full speed rather than at --scan-bytes-per-second, and the first scan past 256 MB
|
|
138
|
+
# records a rollback_scan event with its duration. Switch such a database to WAL mode (PRAGMA
|
|
139
|
+
# journal_mode = WAL), where scans never block writers; Litebackup never changes the journal
|
|
140
|
+
# mode itself.
|
|
141
|
+
# writer_machine_label: the machine label of the last writer this machine saw; empty once this
|
|
142
|
+
# machine released the database, drained it, or offloaded a copy whose write lock it held, as
|
|
143
|
+
# no writer is known then
|
|
144
|
+
# first_unsynced_change_time: when the first change the server lacks was seen; absent when the
|
|
145
|
+
# server has every change seen. It survives restarts and may be earlier than the real first
|
|
146
|
+
# change, never later.
|
|
147
|
+
# next_retry_time: when the next attempt of a failed sync runs; absent when none is scheduled
|
|
148
|
+
# draining: set on a failover origin while this machine drains, and on one a drain released,
|
|
149
|
+
# which holds no write lock until it takes one again; a failover then reports its role as
|
|
150
|
+
# unknown, as after a draining event
|
|
151
|
+
# machine_label: the name this machine shows on the server and as the writer of its databases
|
|
152
|
+
# offload_on_release: the client deletes the released copy once offload_durability holds it
|
|
153
|
+
# offload_durability: what an offload of this acquired copy waits for: server removes the
|
|
154
|
+
# released copy once the server holds its last version, cloud once the bucket holds it too. An
|
|
155
|
+
# acquire, a release with offload, and an explicit offload each save the durability they asked
|
|
156
|
+
# for. Absent when the database is not acquired
|
|
157
|
+
WIRE_FIELDS = {
|
|
158
|
+
name: [:string, true],
|
|
159
|
+
path: [:string, true],
|
|
160
|
+
role: [:string, true],
|
|
161
|
+
state: [:string, true],
|
|
162
|
+
acquired: [:boolean, true],
|
|
163
|
+
failover: [:boolean, true],
|
|
164
|
+
backup_rule_id: [:string, false],
|
|
165
|
+
local_changed: [:boolean, true],
|
|
166
|
+
synced_server: [[:model, :SyncedState], true],
|
|
167
|
+
synced_cloud: [[:model, :ArchivedVersion], true],
|
|
168
|
+
journal_mode: [:string, true],
|
|
169
|
+
page_count: [:integer, true],
|
|
170
|
+
sync_count: [:integer, true],
|
|
171
|
+
hint_misses: [:integer, true],
|
|
172
|
+
last_full_scan_reason: [:string, false],
|
|
173
|
+
writer_machine_label: [:string, false],
|
|
174
|
+
last_error: [:string, false],
|
|
175
|
+
last_error_time: [:time, false],
|
|
176
|
+
first_unsynced_change_time: [:time, false],
|
|
177
|
+
next_retry_time: [:time, false],
|
|
178
|
+
draining: [:boolean, false],
|
|
179
|
+
machine_label: [:string, false],
|
|
180
|
+
maintenance: [:boolean, false],
|
|
181
|
+
offload_on_release: [:boolean, false],
|
|
182
|
+
offload_durability: [:string, false]
|
|
183
|
+
}.freeze
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
class Status < Data.define(:next, :session, :server, :client_version, :session_id, :lease_expires, :watch, :open_file_limit, :unreadable_paths, :databases)
|
|
187
|
+
extend WireModel
|
|
188
|
+
# next: Pass this name as after to read the next page. Omitted on the last page.
|
|
189
|
+
# open_file_limit: The soft limit on open files the daemon runs with. Each active backup holds
|
|
190
|
+
# about four, and the daemon lowers its default number of active backups to fit.
|
|
191
|
+
# unreadable_paths: the paths a backup rule cannot read, most recent first; the events API has
|
|
192
|
+
# the history
|
|
193
|
+
WIRE_FIELDS = {
|
|
194
|
+
next: [:string, false],
|
|
195
|
+
session: [:string, true],
|
|
196
|
+
server: [:string, true],
|
|
197
|
+
client_version: [:string, true],
|
|
198
|
+
session_id: [:string, true],
|
|
199
|
+
lease_expires: [:time, false],
|
|
200
|
+
watch: [:string, true],
|
|
201
|
+
open_file_limit: [:integer, false],
|
|
202
|
+
unreadable_paths: [[:list, [:model, :Event]], false],
|
|
203
|
+
databases: [[:list, [:model, :DatabaseStatus]], true]
|
|
204
|
+
}.freeze
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# What went wrong, in one word. The socket answers with file_exists (the file a restore or an
|
|
208
|
+
# acquire would write, or a -journal, -wal, or -shm beside it, already exists), rule_exists (a
|
|
209
|
+
# backup rule with other settings already covers the path, and the error carries that rule),
|
|
210
|
+
# lock_unavailable (another machine holds the write lock a command asks for, as an acquire, a
|
|
211
|
+
# revert, or a failover does), not_found, still_open, invalid_argument, timeout, cursor_expired
|
|
212
|
+
# (an events cursor older than the oldest event kept), changed (an offload or acquire refused
|
|
213
|
+
# because the local file changed under it: written after its last sync, never synced, or written
|
|
214
|
+
# while an acquire replaced it), rule_database (a release of a database a backup rule on this
|
|
215
|
+
# machine keeps, whose write lock the rule never gives up; stop its backup to hand it off),
|
|
216
|
+
# not_durable (an offload refused until the server, or the bucket when it waits for cloud, holds
|
|
217
|
+
# the synced version, or a cloud wait whose name now holds another server database), and the
|
|
218
|
+
# others by their names; busy (a foreground backup refused because another job, a continuous
|
|
219
|
+
# backup, or another machine writes the database), cancelled (a command interrupted before it
|
|
220
|
+
# finished), drain_required (a credential other than the one the client took its write locks
|
|
221
|
+
# with, refused until a drain released them), and launch_failed (the command could not start the
|
|
222
|
+
# client on this machine, or the client exited before it listened) come from the litebackup
|
|
223
|
+
# command alone, which also answers unauthenticated when this machine has not joined a server. A
|
|
224
|
+
# refusal from the server becomes client_unsupported (426: the server needs a newer litebackup
|
|
225
|
+
# on this machine) or, with 503, not_configured (the server waits for setup), wrong_server (the
|
|
226
|
+
# server this machine reached is not the one its session joined, or does not own the database),
|
|
227
|
+
# unauthenticated (the server no longer accepts this machine's key), forbidden (the key may not
|
|
228
|
+
# do this), plan_limit (the server's plan has no room for another database), or integrity (the
|
|
229
|
+
# version's bucket objects failed an integrity check). lock_unavailable, lock_lost, not_found,
|
|
230
|
+
# invalid_argument, and timeout keep their meaning, and any other refusal (a busy server, one
|
|
231
|
+
# short of disk, one unreachable) is unavailable. A client treats a code it does not know as a
|
|
232
|
+
# failure.
|
|
233
|
+
module ErrorCode
|
|
234
|
+
BUSY = "busy"
|
|
235
|
+
CANCELLED = "cancelled"
|
|
236
|
+
CHANGED = "changed"
|
|
237
|
+
CLIENT_UNSUPPORTED = "client_unsupported"
|
|
238
|
+
CONFLICT = "conflict"
|
|
239
|
+
CURSOR_EXPIRED = "cursor_expired"
|
|
240
|
+
DRAIN_REQUIRED = "drain_required"
|
|
241
|
+
FILE_EXISTS = "file_exists"
|
|
242
|
+
FORBIDDEN = "forbidden"
|
|
243
|
+
INTEGRITY = "integrity"
|
|
244
|
+
INTERNAL = "internal"
|
|
245
|
+
INVALID_ARGUMENT = "invalid_argument"
|
|
246
|
+
LAUNCH_FAILED = "launch_failed"
|
|
247
|
+
LIMIT_EXCEEDED = "limit_exceeded"
|
|
248
|
+
LOCK_LOST = "lock_lost"
|
|
249
|
+
LOCK_UNAVAILABLE = "lock_unavailable"
|
|
250
|
+
METHOD_NOT_ALLOWED = "method_not_allowed"
|
|
251
|
+
NOT_CONFIGURED = "not_configured"
|
|
252
|
+
NOT_DURABLE = "not_durable"
|
|
253
|
+
NOT_FOUND = "not_found"
|
|
254
|
+
PLAN_LIMIT = "plan_limit"
|
|
255
|
+
RULE_DATABASE = "rule_database"
|
|
256
|
+
RULE_EXISTS = "rule_exists"
|
|
257
|
+
SDK_UNSUPPORTED = "sdk_unsupported"
|
|
258
|
+
STILL_OPEN = "still_open"
|
|
259
|
+
TIMEOUT = "timeout"
|
|
260
|
+
UNAUTHENTICATED = "unauthenticated"
|
|
261
|
+
UNAVAILABLE = "unavailable"
|
|
262
|
+
WRONG_SERVER = "wrong_server"
|
|
263
|
+
ALL = [
|
|
264
|
+
BUSY,
|
|
265
|
+
CANCELLED,
|
|
266
|
+
CHANGED,
|
|
267
|
+
CLIENT_UNSUPPORTED,
|
|
268
|
+
CONFLICT,
|
|
269
|
+
CURSOR_EXPIRED,
|
|
270
|
+
DRAIN_REQUIRED,
|
|
271
|
+
FILE_EXISTS,
|
|
272
|
+
FORBIDDEN,
|
|
273
|
+
INTEGRITY,
|
|
274
|
+
INTERNAL,
|
|
275
|
+
INVALID_ARGUMENT,
|
|
276
|
+
LAUNCH_FAILED,
|
|
277
|
+
LIMIT_EXCEEDED,
|
|
278
|
+
LOCK_LOST,
|
|
279
|
+
LOCK_UNAVAILABLE,
|
|
280
|
+
METHOD_NOT_ALLOWED,
|
|
281
|
+
NOT_CONFIGURED,
|
|
282
|
+
NOT_DURABLE,
|
|
283
|
+
NOT_FOUND,
|
|
284
|
+
PLAN_LIMIT,
|
|
285
|
+
RULE_DATABASE,
|
|
286
|
+
RULE_EXISTS,
|
|
287
|
+
SDK_UNSUPPORTED,
|
|
288
|
+
STILL_OPEN,
|
|
289
|
+
TIMEOUT,
|
|
290
|
+
UNAUTHENTICATED,
|
|
291
|
+
UNAVAILABLE,
|
|
292
|
+
WRONG_SERVER
|
|
293
|
+
].freeze
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
class BackupRule < Data.define(:id, :path, :name, :prefix, :watch, :maximum_local_databases, :offload_durability, :offload_rollback_journal, :failover)
|
|
297
|
+
extend WireModel
|
|
298
|
+
# path: the path or glob
|
|
299
|
+
# name: the resolved remote name for a single file, or empty for a directory or glob
|
|
300
|
+
# offload_durability: what maximum_local_databases waits for before it removes a copy
|
|
301
|
+
WIRE_FIELDS = {
|
|
302
|
+
id: [:string, true],
|
|
303
|
+
path: [:string, true],
|
|
304
|
+
name: [:string, true],
|
|
305
|
+
prefix: [:string, true],
|
|
306
|
+
watch: [:string, true],
|
|
307
|
+
maximum_local_databases: [:integer, true],
|
|
308
|
+
offload_durability: [:string, true],
|
|
309
|
+
offload_rollback_journal: [:boolean, true],
|
|
310
|
+
failover: [:boolean, true]
|
|
311
|
+
}.freeze
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
class Error < Data.define(:code, :message, :rule)
|
|
315
|
+
extend WireModel
|
|
316
|
+
# rule: for rule_exists from backup-rules/start, the rule already saved for the path; stop it
|
|
317
|
+
# by its ID before saving different settings
|
|
318
|
+
WIRE_FIELDS = {
|
|
319
|
+
code: [:string, true],
|
|
320
|
+
message: [:string, true],
|
|
321
|
+
rule: [[:model, :BackupRule], false]
|
|
322
|
+
}.freeze
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
class DatabaseStatusList < Data.define(:next, :databases)
|
|
326
|
+
extend WireModel
|
|
327
|
+
# next: Pass this name as after to read the next page. Omitted on the last page.
|
|
328
|
+
WIRE_FIELDS = {
|
|
329
|
+
next: [:string, false],
|
|
330
|
+
databases: [[:list, [:model, :DatabaseStatus]], true]
|
|
331
|
+
}.freeze
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
class RestorableVersion < Data.define(:version, :state_digest, :time, :archived)
|
|
335
|
+
extend WireModel
|
|
336
|
+
# time: when the version was synced
|
|
337
|
+
# archived: when the server recorded the primary bucket's object of this version as archived;
|
|
338
|
+
# absent when the primary bucket does not hold the version, as for one synced between archive
|
|
339
|
+
# passes, which restores only until history pruning removes its segment
|
|
340
|
+
WIRE_FIELDS = {
|
|
341
|
+
version: [:integer, true],
|
|
342
|
+
state_digest: [:string, true],
|
|
343
|
+
time: [:time, true],
|
|
344
|
+
archived: [:time, false]
|
|
345
|
+
}.freeze
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
class VersionList < Data.define(:versions, :next)
|
|
349
|
+
extend WireModel
|
|
350
|
+
# next: pass as after to read the next page
|
|
351
|
+
WIRE_FIELDS = {
|
|
352
|
+
versions: [[:list, [:model, :RestorableVersion]], true],
|
|
353
|
+
next: [:integer, false]
|
|
354
|
+
}.freeze
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
class RestoreRequest < Data.define(:name, :path, :version, :time, :umask)
|
|
358
|
+
extend WireModel
|
|
359
|
+
# path: absolute path of a new file in an existing directory
|
|
360
|
+
# version: the version to restore; the head when neither version nor time is set
|
|
361
|
+
# time: restore the newest version at or before this time
|
|
362
|
+
# umask: the caller's file mode creation mask, such as 18 for 022; the file gets 0666 less it,
|
|
363
|
+
# as one the caller created would. Absent uses the client's own umask. The litebackup command
|
|
364
|
+
# sends its own.
|
|
365
|
+
WIRE_FIELDS = {
|
|
366
|
+
name: [:string, true],
|
|
367
|
+
path: [:string, true],
|
|
368
|
+
version: [:integer, false],
|
|
369
|
+
time: [:time, false],
|
|
370
|
+
umask: [:integer, false]
|
|
371
|
+
}.freeze
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
class RestoreResult < Data.define(:name, :path, :version, :page_count, :page_size, :state_digest)
|
|
375
|
+
extend WireModel
|
|
376
|
+
WIRE_FIELDS = {
|
|
377
|
+
name: [:string, true],
|
|
378
|
+
path: [:string, true],
|
|
379
|
+
version: [:integer, true],
|
|
380
|
+
page_count: [:integer, true],
|
|
381
|
+
page_size: [:integer, true],
|
|
382
|
+
state_digest: [:string, true]
|
|
383
|
+
}.freeze
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
class RevertRequest < Data.define(:name, :version, :time)
|
|
387
|
+
extend WireModel
|
|
388
|
+
# version: the version whose content the new head holds; set version or time
|
|
389
|
+
# time: revert to the newest version at or before this time; set version or time
|
|
390
|
+
WIRE_FIELDS = {
|
|
391
|
+
name: [:string, true],
|
|
392
|
+
version: [:integer, false],
|
|
393
|
+
time: [:time, false]
|
|
394
|
+
}.freeze
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
class RevertResult < Data.define(:database, :source_version, :version, :state_digest)
|
|
398
|
+
extend WireModel
|
|
399
|
+
# source_version: the version whose content the new head holds; it and every version after it
|
|
400
|
+
# stay restorable
|
|
401
|
+
# version: the new head, one past the head before the revert
|
|
402
|
+
# state_digest: the new head's state digest, which is the source version's
|
|
403
|
+
WIRE_FIELDS = {
|
|
404
|
+
database: [[:model, :DatabaseStatus], true],
|
|
405
|
+
source_version: [:integer, true],
|
|
406
|
+
version: [:integer, true],
|
|
407
|
+
state_digest: [:string, true]
|
|
408
|
+
}.freeze
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
class NameRequest < Data.define(:name)
|
|
412
|
+
extend WireModel
|
|
413
|
+
WIRE_FIELDS = {
|
|
414
|
+
name: [:string, true]
|
|
415
|
+
}.freeze
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
class AcquireRequest < Data.define(:name, :path, :maintenance, :discard_local, :offload_on_release, :offload_durability, :machine_label, :timeout_millis, :lock_timeout_millis, :umask)
|
|
419
|
+
extend WireModel
|
|
420
|
+
# path: absolute path of the local file; defaults to the path this machine uses
|
|
421
|
+
# maintenance: checkpoint and, past the freelist threshold, VACUUM on release
|
|
422
|
+
# discard_local: replace a local file that diverged from the server head with the head,
|
|
423
|
+
# discarding its writes the head lacks; without it such a file is refused with 409 conflict
|
|
424
|
+
# and left untouched
|
|
425
|
+
# offload_on_release: lets Litebackup delete the released copy once offload_durability holds
|
|
426
|
+
# it
|
|
427
|
+
# offload_durability: what an offload of the released copy waits for; server, the default,
|
|
428
|
+
# once the server holds its last version, cloud once the bucket holds it too. A release with
|
|
429
|
+
# offload sets it to the release's durability.
|
|
430
|
+
# machine_label: the name this machine shows on the server and as the writer of this database
|
|
431
|
+
# only
|
|
432
|
+
# timeout_millis: bound on downloading the head
|
|
433
|
+
# lock_timeout_millis: how long to wait for the write lock while another machine holds it,
|
|
434
|
+
# trying again until it is released; 0 refuses at once with lock_unavailable. It adds to the
|
|
435
|
+
# timeout.
|
|
436
|
+
# umask: the caller's file mode creation mask, such as 18 for 022; a file the acquire creates,
|
|
437
|
+
# the head downloaded where none was or the empty file an offload removed, gets 0666 less it,
|
|
438
|
+
# as one the caller created would. A copy the head replaces keeps its bits. Absent uses the
|
|
439
|
+
# client's own umask. The litebackup command sends its own.
|
|
440
|
+
WIRE_FIELDS = {
|
|
441
|
+
name: [:string, true],
|
|
442
|
+
path: [:string, false],
|
|
443
|
+
maintenance: [:boolean, false],
|
|
444
|
+
discard_local: [:boolean, false],
|
|
445
|
+
offload_on_release: [:boolean, false],
|
|
446
|
+
offload_durability: [:string, false],
|
|
447
|
+
machine_label: [:string, false],
|
|
448
|
+
timeout_millis: [:integer, false],
|
|
449
|
+
lock_timeout_millis: [:integer, false],
|
|
450
|
+
umask: [:integer, false]
|
|
451
|
+
}.freeze
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
class AcquireResult < Data.define(:database, :decision)
|
|
455
|
+
extend WireModel
|
|
456
|
+
DECISION_CREATED = "created"
|
|
457
|
+
DECISION_MATCHED = "matched"
|
|
458
|
+
DECISION_RESUMED = "resumed"
|
|
459
|
+
DECISION_DOWNLOADED = "downloaded"
|
|
460
|
+
DECISION_FAST_FORWARDED = "fast_forwarded"
|
|
461
|
+
DECISION_REPLACED = "replaced"
|
|
462
|
+
|
|
463
|
+
# decision: what the acquire did to the local file
|
|
464
|
+
WIRE_FIELDS = {
|
|
465
|
+
database: [[:model, :DatabaseStatus], true],
|
|
466
|
+
decision: [:string, true]
|
|
467
|
+
}.freeze
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
class ReleaseRequest < Data.define(:name, :durability, :offload, :timeout_millis)
|
|
471
|
+
extend WireModel
|
|
472
|
+
# durability: server returns once the final sync is acknowledged; cloud waits for the bucket
|
|
473
|
+
# too
|
|
474
|
+
# offload: remove the local file once durability holds the released version, the server with
|
|
475
|
+
# server and the bucket with cloud; an offload refused as not_durable is left to a later
|
|
476
|
+
# offload pass
|
|
477
|
+
# timeout_millis: how long to wait for the database to close and for the chosen durability
|
|
478
|
+
WIRE_FIELDS = {
|
|
479
|
+
name: [:string, true],
|
|
480
|
+
durability: [:string, false],
|
|
481
|
+
offload: [:boolean, false],
|
|
482
|
+
timeout_millis: [:integer, false]
|
|
483
|
+
}.freeze
|
|
484
|
+
end
|
|
485
|
+
|
|
486
|
+
class ReleaseResult < Data.define(:database, :checkpointed, :vacuumed, :offloaded)
|
|
487
|
+
extend WireModel
|
|
488
|
+
WIRE_FIELDS = {
|
|
489
|
+
database: [[:model, :DatabaseStatus], true],
|
|
490
|
+
checkpointed: [:boolean, true],
|
|
491
|
+
vacuumed: [:boolean, true],
|
|
492
|
+
offloaded: [:boolean, true]
|
|
493
|
+
}.freeze
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
class OffloadRequest < Data.define(:name, :durability)
|
|
497
|
+
extend WireModel
|
|
498
|
+
# durability: what the offload waits for before it removes the copy: server, the default, once
|
|
499
|
+
# the server holds its synced version; cloud once the bucket holds it too. Until then it is
|
|
500
|
+
# refused with not_durable.
|
|
501
|
+
WIRE_FIELDS = {
|
|
502
|
+
name: [:string, true],
|
|
503
|
+
durability: [:string, false]
|
|
504
|
+
}.freeze
|
|
505
|
+
end
|
|
506
|
+
|
|
507
|
+
class Writer < Data.define(:name, :active, :this_machine, :writer_machine_label, :acquired_time, :lease_expires, :lease_remaining_millis, :lapsed)
|
|
508
|
+
extend WireModel
|
|
509
|
+
# active: whether some machine holds the write lock and its lease still runs
|
|
510
|
+
# this_machine: whether this machine's session holds the write lock
|
|
511
|
+
# writer_machine_label: the machine label of the writer, or empty when nobody holds the lock
|
|
512
|
+
# acquired_time: when the writer took the lock
|
|
513
|
+
# lease_expires: on the server's clock
|
|
514
|
+
# lease_remaining_millis: how long the lease still runs, negative once it ran out
|
|
515
|
+
# lapsed: the writer's lease ran out, so another machine may take over
|
|
516
|
+
WIRE_FIELDS = {
|
|
517
|
+
name: [:string, true],
|
|
518
|
+
active: [:boolean, true],
|
|
519
|
+
this_machine: [:boolean, true],
|
|
520
|
+
writer_machine_label: [:string, true],
|
|
521
|
+
acquired_time: [:time, false],
|
|
522
|
+
lease_expires: [:time, false],
|
|
523
|
+
lease_remaining_millis: [:integer, false],
|
|
524
|
+
lapsed: [:boolean, true]
|
|
525
|
+
}.freeze
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
class BackupRequest < Data.define(:path, :name, :prefix, :watch, :maximum_local_databases, :offload_durability, :offload_rollback_journal)
|
|
529
|
+
extend WireModel
|
|
530
|
+
WATCH_INOTIFY = "inotify"
|
|
531
|
+
WATCH_POLL = "poll"
|
|
532
|
+
|
|
533
|
+
# path: absolute file, directory, or glob with optional ** segments
|
|
534
|
+
# name: the database name for a single path; must already be a valid name
|
|
535
|
+
# prefix: name prefix such as app/ (a trailing / is added when missing); names are the prefix
|
|
536
|
+
# plus the relative file path
|
|
537
|
+
# maximum_local_databases: when positive, offload the least recently changed idle databases
|
|
538
|
+
# past this count once offload_durability holds them
|
|
539
|
+
# offload_durability: what maximum_local_databases waits for before it removes a copy; server,
|
|
540
|
+
# the default, once the server holds its last version, cloud once the bucket holds it too
|
|
541
|
+
# offload_rollback_journal: lets maximum_local_databases offload rollback-journal databases
|
|
542
|
+
# too, on the operator's word that nothing keeps them open while idle; WAL databases are
|
|
543
|
+
# offloaded either way
|
|
544
|
+
WIRE_FIELDS = {
|
|
545
|
+
path: [:string, true],
|
|
546
|
+
name: [:string, false],
|
|
547
|
+
prefix: [:string, false],
|
|
548
|
+
watch: [:string, false],
|
|
549
|
+
maximum_local_databases: [:integer, false],
|
|
550
|
+
offload_durability: [:string, false],
|
|
551
|
+
offload_rollback_journal: [:boolean, false]
|
|
552
|
+
}.freeze
|
|
553
|
+
end
|
|
554
|
+
|
|
555
|
+
class BackupList < Data.define(:rules)
|
|
556
|
+
extend WireModel
|
|
557
|
+
WIRE_FIELDS = {
|
|
558
|
+
rules: [[:list, [:model, :BackupRule]], true]
|
|
559
|
+
}.freeze
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
class StopBackupRequest < Data.define(:name, :rule_id)
|
|
563
|
+
extend WireModel
|
|
564
|
+
# name: Exact remote name of a database with its own backup rule on this machine.
|
|
565
|
+
# rule_id: ID returned by start or listed by rules. Stops the whole rule, including future
|
|
566
|
+
# matches.
|
|
567
|
+
WIRE_FIELDS = {
|
|
568
|
+
name: [:string, false],
|
|
569
|
+
rule_id: [:string, false]
|
|
570
|
+
}.freeze
|
|
571
|
+
end
|
|
572
|
+
|
|
573
|
+
class StopBackupResult < Data.define(:lease_pending)
|
|
574
|
+
extend WireModel
|
|
575
|
+
WIRE_FIELDS = {
|
|
576
|
+
lease_pending: [:boolean, true]
|
|
577
|
+
}.freeze
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
class FailoverRequest < Data.define(:path, :name, :timeout_millis, :discard_local)
|
|
581
|
+
extend WireModel
|
|
582
|
+
# path: absolute path of the database, the same on every machine
|
|
583
|
+
# name: the database name; defaults to the relative file path
|
|
584
|
+
# timeout_millis: bound on the first download of a replica
|
|
585
|
+
# discard_local: replace a file at the path that differs from the server head with the head,
|
|
586
|
+
# discarding its writes the head lacks; without it such a file is refused with 409 conflict
|
|
587
|
+
# and left untouched
|
|
588
|
+
WIRE_FIELDS = {
|
|
589
|
+
path: [:string, true],
|
|
590
|
+
name: [:string, false],
|
|
591
|
+
timeout_millis: [:integer, false],
|
|
592
|
+
discard_local: [:boolean, false]
|
|
593
|
+
}.freeze
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
class Failover < Data.define(:name, :path, :role, :database, :writer)
|
|
597
|
+
extend WireModel
|
|
598
|
+
ROLE_ORIGIN = "origin"
|
|
599
|
+
ROLE_REPLICA = "replica"
|
|
600
|
+
|
|
601
|
+
WIRE_FIELDS = {
|
|
602
|
+
name: [:string, true],
|
|
603
|
+
path: [:string, true],
|
|
604
|
+
role: [:string, true],
|
|
605
|
+
database: [[:model, :DatabaseStatus], true],
|
|
606
|
+
writer: [[:model, :Writer], true]
|
|
607
|
+
}.freeze
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
# Either name and path, for one database, or prefix and directory, for every database under it.
|
|
611
|
+
class ReplicaRequest < Data.define(:name, :path, :prefix, :directory, :write_protection, :timeout_millis)
|
|
612
|
+
extend WireModel
|
|
613
|
+
WRITE_PROTECTION_LOCK = "lock"
|
|
614
|
+
WRITE_PROTECTION_DETECT = "detect"
|
|
615
|
+
WRITE_PROTECTION_NONE = "none"
|
|
616
|
+
|
|
617
|
+
# path: with name, the replica file, defaulting to the path this machine uses
|
|
618
|
+
# prefix: name prefix such as app; replicates every database under it
|
|
619
|
+
# directory: with prefix, the directory that receives <directory>/<name relative to the
|
|
620
|
+
# prefix>
|
|
621
|
+
# write_protection: lock (default) holds the SQLite write lock so app writes get SQLITE_BUSY
|
|
622
|
+
# while readers carry on; detect rebases after a local write; none trusts apps to open with
|
|
623
|
+
# mode=ro
|
|
624
|
+
# timeout_millis: bound on downloading the first version of a single replica
|
|
625
|
+
WIRE_FIELDS = {
|
|
626
|
+
name: [:string, false],
|
|
627
|
+
path: [:string, false],
|
|
628
|
+
prefix: [:string, false],
|
|
629
|
+
directory: [:string, false],
|
|
630
|
+
write_protection: [:string, false],
|
|
631
|
+
timeout_millis: [:integer, false]
|
|
632
|
+
}.freeze
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
class PrefixReplica < Data.define(:id, :prefix, :directory, :write_protection, :database_count)
|
|
636
|
+
extend WireModel
|
|
637
|
+
# directory: the directory that receives <directory>/<name relative to the prefix>
|
|
638
|
+
# database_count: how many databases under the prefix this machine replicates
|
|
639
|
+
WIRE_FIELDS = {
|
|
640
|
+
id: [:string, true],
|
|
641
|
+
prefix: [:string, true],
|
|
642
|
+
directory: [:string, true],
|
|
643
|
+
write_protection: [:string, true],
|
|
644
|
+
database_count: [:integer, true]
|
|
645
|
+
}.freeze
|
|
646
|
+
end
|
|
647
|
+
|
|
648
|
+
# The replica for a name, or the prefix replica for a prefix.
|
|
649
|
+
class ReplicaResult < Data.define(:database, :prefix_replica)
|
|
650
|
+
extend WireModel
|
|
651
|
+
WIRE_FIELDS = {
|
|
652
|
+
database: [[:model, :DatabaseStatus], false],
|
|
653
|
+
prefix_replica: [[:model, :PrefixReplica], false]
|
|
654
|
+
}.freeze
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
class ReplicaList < Data.define(:prefixes, :replicas)
|
|
658
|
+
extend WireModel
|
|
659
|
+
WIRE_FIELDS = {
|
|
660
|
+
prefixes: [[:list, [:model, :PrefixReplica]], true],
|
|
661
|
+
replicas: [[:list, [:model, :DatabaseStatus]], true]
|
|
662
|
+
}.freeze
|
|
663
|
+
end
|
|
664
|
+
|
|
665
|
+
# Either name for one replica, or prefix and directory for a prefix.
|
|
666
|
+
class StopReplicaRequest < Data.define(:name, :prefix, :directory)
|
|
667
|
+
extend WireModel
|
|
668
|
+
# directory: with prefix, the directory the prefix replica was started with
|
|
669
|
+
WIRE_FIELDS = {
|
|
670
|
+
name: [:string, false],
|
|
671
|
+
prefix: [:string, false],
|
|
672
|
+
directory: [:string, false]
|
|
673
|
+
}.freeze
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
class Empty < Data.define
|
|
677
|
+
extend WireModel
|
|
678
|
+
WIRE_FIELDS = {}.freeze
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
class EventList < Data.define(:events, :next)
|
|
682
|
+
extend WireModel
|
|
683
|
+
# next: pass as after to continue
|
|
684
|
+
WIRE_FIELDS = {
|
|
685
|
+
events: [[:list, [:model, :Event]], true],
|
|
686
|
+
next: [:integer, true]
|
|
687
|
+
}.freeze
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
class ShutdownRequest < Data.define(:durability, :timeout_millis)
|
|
691
|
+
extend WireModel
|
|
692
|
+
DURABILITY_NONE = "none"
|
|
693
|
+
DURABILITY_SERVER = "server"
|
|
694
|
+
DURABILITY_CLOUD = "cloud"
|
|
695
|
+
|
|
696
|
+
WIRE_FIELDS = {
|
|
697
|
+
durability: [:string, false],
|
|
698
|
+
timeout_millis: [:integer, false]
|
|
699
|
+
}.freeze
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
class DrainFailure < Data.define(:name, :code, :message)
|
|
703
|
+
extend WireModel
|
|
704
|
+
WIRE_FIELDS = {
|
|
705
|
+
name: [:string, true],
|
|
706
|
+
code: [:string, true],
|
|
707
|
+
message: [:string, true]
|
|
708
|
+
}.freeze
|
|
709
|
+
end
|
|
710
|
+
|
|
711
|
+
class ShutdownResult < Data.define(:released, :failed)
|
|
712
|
+
extend WireModel
|
|
713
|
+
# released: how many databases the drain synced as asked and released
|
|
714
|
+
# failed: every database the drain could not sync, wait for, or release, each keeping any
|
|
715
|
+
# write lock it holds, and every conflicted copy whose writes are not on the server, with
|
|
716
|
+
# conflict; empty only when the drain released every database it covers, which is the one case
|
|
717
|
+
# the daemon stops
|
|
718
|
+
WIRE_FIELDS = {
|
|
719
|
+
released: [:integer, true],
|
|
720
|
+
failed: [[:list, [:model, :DrainFailure]], true]
|
|
721
|
+
}.freeze
|
|
722
|
+
end
|
|
723
|
+
end
|
|
724
|
+
end
|