Class: Couchbase::Protostellar::Cluster Private
- Inherits:
-
Object
- Object
- Couchbase::Protostellar::Cluster
- Defined in:
- lib/couchbase/protostellar/cluster.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Constant Summary collapse
- VALID_CONNECTION_STRING_PARAMS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ "trust_certificate", ].freeze
Instance Attribute Summary collapse
- #client ⇒ Object readonly private
Class Method Summary collapse
-
.connect(connection_string_or_config, *args) ⇒ Object
private
Connect to the Couchbase cluster.
- .parse_connection_string_params(connection_string) ⇒ Object private
Instance Method Summary collapse
- #bucket(name) ⇒ Object private
- #buckets ⇒ Object private
- #diagnostics(_options = Options::Diagnostics::DEFAULT) ⇒ Object private
- #disconnect ⇒ Object private
- #ping(_options = Options::Ping::DEFAULT) ⇒ Object private
- #query(statement, options = Couchbase::Options::Query::DEFAULT) ⇒ Object private
- #query_indexes ⇒ Object private
- #search_indexes ⇒ Object private
- #search_query(index_name, query, options = Couchbase::Options::Search::DEFAULT) ⇒ Object private
Instance Attribute Details
#client ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
26 27 28 |
# File 'lib/couchbase/protostellar/cluster.rb', line 26 def client @client end |
Class Method Details
.connect(connection_string, options) ⇒ Object .connect(connection_string, username, password, options) ⇒ Object .connect(configuration, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Connect to the Couchbase cluster
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/couchbase/protostellar/cluster.rb', line 44 def self.connect(connection_string_or_config, *args) require_relative "connect_options" require_relative "bucket" require_relative "client" require_relative "timeouts" require_relative "management/bucket_manager" require_relative "request_generator/query" require_relative "request_generator/search" require_relative "response_converter/query" require_relative "response_converter/search" require_relative "management/query_index_manager" connection_string = nil username = nil password = nil = nil if connection_string_or_config.is_a?(Couchbase::Configuration) connection_string = connection_string_or_config.connection_string username = connection_string_or_config.username password = connection_string_or_config.password = args[0] || Couchbase::Options::Cluster.new else connection_string = connection_string_or_config case args[0] when String username = args[0] password = args[1] = args[2] || Couchbase::Options::Cluster.new when Couchbase::Options::Cluster = args[0] case .authenticator when Couchbase::PasswordAuthenticator username = .authenticator.username password = .authenticator.password when Couchbase::CertificateAuthenticator raise Couchbase::Error::FeatureNotAvailable, "The #{Couchbase::Protostellar::NAME} protocol does not support the CertificateAuthenticator" when Couchbase::JWTAuthenticator raise Couchbase::Error::FeatureNotAvailable, "The #{Couchbase::Protostellar::NAME} protocol does not support the JWTAuthenticator" else raise ArgumentError, "options must have authenticator configured" end else raise ArgumentError, "unexpected second argument, have to be String or Couchbase::Options::Cluster" end end raise ArgumentError, "missing username" unless username raise ArgumentError, "missing password" unless password params = parse_connection_string_params(connection_string) = ConnectOptions.new( username: username, password: password, timeouts: Protostellar::Timeouts.(), root_certificates: params.key?("trust_certificate") ? File.read(params["trust_certificate"]) : nil, ) new(connection_string.split("://")[1].split("?")[0], ) end |
.parse_connection_string_params(connection_string) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/couchbase/protostellar/cluster.rb', line 106 def self.parse_connection_string_params(connection_string) params = if connection_string.include?("?") connection_string.split("?")[1].split("&").to_h { |p| p.split("=") } else {} end # Show warnings for the connection string parameters that are not supported params.each do |k, v| warn "Unsupported parameter '#{k}' in connection string (value '#{v}')" unless VALID_CONNECTION_STRING_PARAMS.include?(k) end params end |
Instance Method Details
#bucket(name) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
126 127 128 |
# File 'lib/couchbase/protostellar/cluster.rb', line 126 def bucket(name) Bucket.new(@client, name) end |
#buckets ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
130 131 132 |
# File 'lib/couchbase/protostellar/cluster.rb', line 130 def buckets Management::BucketManager.new(@client) end |
#diagnostics(_options = Options::Diagnostics::DEFAULT) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
150 151 152 |
# File 'lib/couchbase/protostellar/cluster.rb', line 150 def diagnostics( = Options::Diagnostics::DEFAULT) raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support diagnostics" end |
#disconnect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
122 123 124 |
# File 'lib/couchbase/protostellar/cluster.rb', line 122 def disconnect @client.close end |
#ping(_options = Options::Ping::DEFAULT) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
154 155 156 |
# File 'lib/couchbase/protostellar/cluster.rb', line 154 def ping( = Options::Ping::DEFAULT) raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support ping" end |
#query(statement, options = Couchbase::Options::Query::DEFAULT) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
138 139 140 141 142 |
# File 'lib/couchbase/protostellar/cluster.rb', line 138 def query(statement, = Couchbase::Options::Query::DEFAULT) req = @query_request_generator.query_request(statement, ) resps = @client.send_request(req) ResponseConverter::Query.to_query_result(resps) end |
#query_indexes ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
134 135 136 |
# File 'lib/couchbase/protostellar/cluster.rb', line 134 def query_indexes Management::QueryIndexManager.new(client: @client) end |
#search_indexes ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
158 159 160 |
# File 'lib/couchbase/protostellar/cluster.rb', line 158 def search_indexes raise Couchbase::Error::FeatureNotAvailable, "The #{Protostellar::NAME} protocol does not support search index management" end |
#search_query(index_name, query, options = Couchbase::Options::Search::DEFAULT) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
144 145 146 147 148 |
# File 'lib/couchbase/protostellar/cluster.rb', line 144 def search_query(index_name, query, = Couchbase::Options::Search::DEFAULT) req = @search_request_generator.search_query_request(index_name, query, ) resp = @client.send_request(req) ResponseConverter::Search.to_search_result(resp, ) end |