Class: Epsilla::Client
- Inherits:
-
Object
- Object
- Epsilla::Client
- Defined in:
- lib/epsilla/client.rb
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
- #database ⇒ Object
-
#initialize(protocol, host, port, adapter: Faraday.default_adapter, debug: false) ⇒ Client
constructor
A new instance of Client.
- #live? ⇒ Boolean
- #state ⇒ Object
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
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
8 9 10 |
# File 'lib/epsilla/client.rb', line 8 def adapter @adapter end |
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
8 9 10 |
# File 'lib/epsilla/client.rb', line 8 def debug @debug end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/epsilla/client.rb', line 8 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/epsilla/client.rb', line 8 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
8 9 10 |
# File 'lib/epsilla/client.rb', line 8 def protocol @protocol end |
Class Method Details
.welcome ⇒ Object
10 11 12 |
# File 'lib/epsilla/client.rb', line 10 def self.welcome puts "WELCOME To EPSILLA VECTOR DATABASE!" end |
Instance Method Details
#connection ⇒ Object
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..timeout = 30 # 30s faraday..open_timeout = 30 # 30s faraday.headers['Content-type'] = 'application/json' end end |
#database ⇒ Object
43 44 45 |
# File 'lib/epsilla/client.rb', line 43 def database @database ||= Epsilla::DataBase.new(client: self) end |