Class: Chroma::Resources::Database

Inherits:
Object
  • Object
show all
Includes:
APIOperations::Request
Defined in:
lib/chroma/resources/database.rb

Overview

The Database class provides methods for interacting with the Chroma database server.

Class Method Summary collapse

Methods included from APIOperations::Request

included

Class Method Details

.heartbeatObject

Check the heartbeat of the Chroma database server.

Return a Hash with a timestamp.



46
47
48
49
50
51
52
# File 'lib/chroma/resources/database.rb', line 46

def self.heartbeat
  result = execute_request(:get, "#{Chroma.api_url}/heartbeat")

  return result.success.body if result.success?

  raise_failure_error(result)
end

.persistObject

Persist Chroma database data.

Resturn true on success or raise a Chroma::Error on failure.



35
36
37
38
39
40
41
# File 'lib/chroma/resources/database.rb', line 35

def self.persist
  result = execute_request(:post, "#{Chroma.api_url}/persist")

  return result.success.body if result.success?

  raise_failure_error(result)
end

.resetObject

Reset the Chroma database server. This can’t be undone.

Returns true on success or raise a Chroma::Error on failure.



24
25
26
27
28
29
30
# File 'lib/chroma/resources/database.rb', line 24

def self.reset
  result = execute_request(:post, "#{Chroma.api_url}/reset")

  return result.success.body if result.success?

  raise_failure_error(result)
end

.versionObject

Get the version of the Chroma database server.

Returns the version of the Chroma database server.



13
14
15
16
17
18
19
# File 'lib/chroma/resources/database.rb', line 13

def self.version
  result = execute_request(:get, "#{Chroma.api_url}/version")

  return result.success.body if result.success?

  raise_failure_error(result)
end