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

Parameters:

  • path (String)

    Database path

  • url (String, nil) (defaults to: nil)

    Optional object store URL

Returns:

  • (Admin)

    The admin handle



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

Parameters:

  • lifetime (Integer, nil) (defaults to: nil)

    Checkpoint lifetime in milliseconds

  • source (String, nil) (defaults to: nil)

    Source checkpoint UUID string to extend/refresh

  • name (String, nil) (defaults to: nil)

    Checkpoint name

Returns:

  • (Hash)

    Hash with :id (UUID string) and :manifest_id (Integer)



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")

Parameters:

  • id (String)

    Checkpoint UUID string



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

Parameters:

  • name (String, nil) (defaults to: nil)

    Optional checkpoint name filter

Returns:

  • (Array<Hash>)

    Array of checkpoint hashes



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)

Parameters:

  • start (Integer, nil) (defaults to: nil)

    Optional inclusive start id

  • end_id (Integer, nil) (defaults to: nil)

    Optional exclusive end id

Returns:

  • (String)

    JSON string containing a list of manifest metadata



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)

Parameters:

  • id (Integer, nil) (defaults to: nil)

    Optional manifest id to read. If nil, reads the latest.

Returns:

  • (String, nil)

    JSON string of the manifest, or nil if no manifests exist



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)

Parameters:

  • id (String)

    Checkpoint UUID string

  • lifetime (Integer, nil) (defaults to: nil)

    New lifetime in milliseconds



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

Parameters:

  • min_age (Integer, nil) (defaults to: nil)

    Minimum age in milliseconds for objects to be collected



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