Class: SlateDb::Admin

Inherits:
Object
  • Object
show all
Defined in:
lib/slatedb/admin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(path, url: nil) ⇒ Admin

Create an admin handle for a database path/object store.

Examples:

admin = SlateDb::Admin.new("/tmp/mydb")
checkpoints = admin.list_checkpoints


16
17
18
# File 'lib/slatedb/admin.rb', line 16

def new(path, url: nil)
  _new(path, url)
end

Instance Method Details

#create_checkpoint(lifetime: nil, source: nil, name: nil) ⇒ Hash

Create a detached checkpoint.

Examples:

result = admin.create_checkpoint(name: "my_checkpoint")
puts result[:id]         # => "uuid-string"
puts result[:manifest_id] # => 7


60
61
62
63
64
65
66
# File 'lib/slatedb/admin.rb', line 60

def create_checkpoint(lifetime: nil, source: nil, name: nil)
  opts = {}
  opts[:lifetime] = lifetime if lifetime
  opts[:source] = source if source
  opts[:name] = name if name
  _create_checkpoint(opts)
end

#delete_checkpoint(id) ⇒ void

This method returns an undefined value.

Delete a checkpoint.

Examples:

admin.delete_checkpoint("uuid-here")


104
105
106
# File 'lib/slatedb/admin.rb', line 104

def delete_checkpoint(id)
  _delete_checkpoint(id)
end

#list_checkpoints(name: nil) ⇒ Array<Hash>

List known checkpoints for the database.

Examples:

checkpoints = admin.list_checkpoints
checkpoints.each do |cp|
  puts "#{cp[:id]}: #{cp[:name]}"
end


79
80
81
# File 'lib/slatedb/admin.rb', line 79

def list_checkpoints(name: nil)
  _list_checkpoints(name)
end

#list_manifests(start: nil, end_id: nil) ⇒ String

List manifests within an optional [start, end) range as JSON.

Examples:

json = admin.list_manifests
json = admin.list_manifests(start: 1, end_id: 10)


44
45
46
# File 'lib/slatedb/admin.rb', line 44

def list_manifests(start: nil, end_id: nil)
  _list_manifests(start, end_id)
end

#read_manifest(id = nil) ⇒ String?

Read the latest or a specific manifest as a JSON string.

Examples:

json = admin.read_manifest
json = admin.read_manifest(123)


30
31
32
# File 'lib/slatedb/admin.rb', line 30

def read_manifest(id = nil)
  _read_manifest(id)
end

#refresh_checkpoint(id, lifetime: nil) ⇒ void

This method returns an undefined value.

Refresh a checkpoint’s lifetime.

Examples:

admin.refresh_checkpoint("uuid-here", lifetime: 60_000)


92
93
94
# File 'lib/slatedb/admin.rb', line 92

def refresh_checkpoint(id, lifetime: nil)
  _refresh_checkpoint(id, lifetime)
end

#run_gc(min_age: nil) ⇒ void

This method returns an undefined value.

Run garbage collection once.

Examples:

admin.run_gc(min_age: 3600_000) # 1 hour


116
117
118
119
120
# File 'lib/slatedb/admin.rb', line 116

def run_gc(min_age: nil)
  opts = {}
  opts[:min_age] = min_age if min_age
  _run_gc(opts)
end