Class: TypesenseModel::Configuration
- Inherits:
-
Object
- Object
- TypesenseModel::Configuration
- Defined in:
- lib/typesense_model/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#connection_timeout_seconds ⇒ Object
Returns the value of attribute connection_timeout_seconds.
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
Instance Method Summary collapse
- #client ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 14 |
# File 'lib/typesense_model/configuration.rb', line 7 def initialize @api_key = nil @host = 'localhost' @port = 8108 @protocol = 'http' @connection_timeout_seconds = 5 @client_mutex = Mutex.new end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/typesense_model/configuration.rb', line 5 def api_key @api_key end |
#connection_timeout_seconds ⇒ Object
Returns the value of attribute connection_timeout_seconds.
5 6 7 |
# File 'lib/typesense_model/configuration.rb', line 5 def connection_timeout_seconds @connection_timeout_seconds end |
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/typesense_model/configuration.rb', line 5 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/typesense_model/configuration.rb', line 5 def port @port end |
#protocol ⇒ Object
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/typesense_model/configuration.rb', line 5 def protocol @protocol end |
Instance Method Details
#client ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/typesense_model/configuration.rb', line 16 def client return @client if @client @client_mutex.synchronize do @client ||= Typesense::Client.new( api_key: api_key, nodes: [{ host: host, port: port, protocol: protocol }], connection_timeout_seconds: connection_timeout_seconds ) end end |