Class: Chroma::ChromaConfiguration

Inherits:
Object
  • Object
show all
Defined in:
lib/chroma/chroma_configuration.rb

Overview

The ChromaConfiguration class allows you to configure the connection settings for a Chroma service client. It can be initialized directly calling #new method.

Examples

configuration = Chroma::ChromaConfiguration.new
configurarion.connect_host = "https://chroma.example.com"

Or via a setup block.

Examples

Chroma::ChromaConfiguration.setup do |config|
  config.connect_host = "https://chroma.example.com"
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChromaConfiguration

Returns a new instance of ChromaConfiguration.



95
96
97
98
99
100
101
102
103
# File 'lib/chroma/chroma_configuration.rb', line 95

def initialize
  @api_base = "api"
  @api_version = "v1"

  @log_level = Chroma::LEVEL_INFO

  @tenant ||= "default_tenant"
  @database ||= "default_database"
end

Instance Attribute Details

#api_baseObject

Sets the base path for the Chroma API.

Examples

config.api_base = "/api"

Returns the String API base path.



63
64
65
# File 'lib/chroma/chroma_configuration.rb', line 63

def api_base
  @api_base
end

#api_keyObject

Sets the API Key for the Chroma service, for ‘x-chroma-token` header.

Examples

config.api_key = "1234abcd"

Returns the String database.



54
55
56
# File 'lib/chroma/chroma_configuration.rb', line 54

def api_key
  @api_key
end

#api_versionObject

Sets the version of the Chroma API.

Examples

config.api_version = "v1"

Returns the String API version.



71
72
73
# File 'lib/chroma/chroma_configuration.rb', line 71

def api_version
  @api_version
end

#connect_hostObject

Sets the host name for the Chroma service.

Examples

config.connect_host = "chroma.example.com"

Returns the String host name.



27
28
29
# File 'lib/chroma/chroma_configuration.rb', line 27

def connect_host
  @connect_host
end

#databaseObject

Sets the database for the Chroma service, Defaults to ‘default_database’.

Examples

config.database = "my_database"

Returns the String database.



45
46
47
# File 'lib/chroma/chroma_configuration.rb', line 45

def database
  @database
end

#log_levelObject

Sets the logger’s log level for the Chroma service client.

Examples

config.log_level = Chroma::LEVEL_INFO

Returns the log level constant



87
88
89
# File 'lib/chroma/chroma_configuration.rb', line 87

def log_level
  @log_level
end

#loggerObject

Sets the logger for the Chroma service client.

Examples

config.logger = Logger.new(STDOUT)

Returns the Logger instance.



79
80
81
# File 'lib/chroma/chroma_configuration.rb', line 79

def logger
  @logger
end

#tenantObject

Sets the tenant for the Chroma service, Defaults to ‘default_tenant’.

Examples

config.tenant = "my_tenant"

Returns the String tenant.



36
37
38
# File 'lib/chroma/chroma_configuration.rb', line 36

def tenant
  @tenant
end

Class Method Details

.setupObject



89
90
91
92
93
# File 'lib/chroma/chroma_configuration.rb', line 89

def self.setup
  new.tap do |instance|
    yield(instance) if block_given?
  end
end