Class: Epsilla::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/epsilla/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(protocol, host, port, adapter: Faraday.default_adapter, debug: false) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
# File 'lib/epsilla/client.rb', line 14

def initialize(protocol, host, port, adapter: Faraday.default_adapter, debug: false)
  @url = "#{protocol}://#{host}:#{port}"
  @adapter = adapter
  @debug = debug
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



8
9
10
# File 'lib/epsilla/client.rb', line 8

def adapter
  @adapter
end

#debugObject (readonly)

Returns the value of attribute debug.



8
9
10
# File 'lib/epsilla/client.rb', line 8

def debug
  @debug
end

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/epsilla/client.rb', line 8

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/epsilla/client.rb', line 8

def port
  @port
end

#protocolObject (readonly)

Returns the value of attribute protocol.



8
9
10
# File 'lib/epsilla/client.rb', line 8

def protocol
  @protocol
end

Class Method Details

.welcomeObject



10
11
12
# File 'lib/epsilla/client.rb', line 10

def self.welcome
  puts "WELCOME To EPSILLA VECTOR DATABASE!"
end

Instance Method Details

#connectionObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/epsilla/client.rb', line 21

def connection
  @conn ||= Faraday.new(url: "#{@url}", request: { timeout: 30 }) do |faraday|
    faraday.request :json
    faraday.response :logger if @debug
    faraday.response :json, content_type: /\bjson$/
    faraday.adapter @adapter
    faraday.options.timeout = 30 # 30s
    faraday.options.open_timeout = 30 # 30s
    faraday.headers['Content-type'] = 'application/json'
  end
end

#databaseObject



43
44
45
# File 'lib/epsilla/client.rb', line 43

def database
  @database ||= Epsilla::DataBase.new(client: self)
end

#live?Boolean

Returns:

  • (Boolean)


33
34
35
36
# File 'lib/epsilla/client.rb', line 33

def live?
  @health ||= Epsilla::Health.new(client: self)
  @health.live?
end

#stateObject



38
39
40
41
# File 'lib/epsilla/client.rb', line 38

def state
  @health ||= Epsilla::Health.new(client: self)
  @health.state
end