struct
CryBase::CouchBase::ConnectionString
Overview
Parses a Couchbase connection string of the form:
couchbase://host[,host2][:port]— plaintextcouchbases://host[,host2][:port]— TLScouchbase://user:pass@host[:port]/bucket?params— KV credentials/optionshttp(s)://host[:port]— treated as the Management URL
cs = CryBase::CouchBase::ConnectionString.parse(
"couchbases://user:pass@n1,n2:11207/default?tls_verify=false"
)
cs.hosts # => ["n1", "n2"]
cs.tls? # => true
cs.explicit_port # => 11207
cs.username # => "user"
cs.bucket # => "default"
Defined in:
crybase/couchbase/connection_string.crConstructors
- .new(hosts : Array(String), tls : Bool, explicit_port : Int32 | Nil = nil, username : String | Nil = nil, password : String | Nil = nil, bucket : String | Nil = nil, params : URI::Params = URI::Params.new, ports : Array(Int32 | Nil) = [] of Int32 | ::Nil)
-
.parse(input : String) : ConnectionString
Parses input into a
ConnectionString.
Instance Method Summary
-
#bool_param(name : String, default : Bool) : Bool
Reads a boolean query parameter.
- #bucket : String | Nil
-
#explicit_port : Int32 | Nil
Port explicitly given in the URI, or
nilwhen none was supplied. -
#hosts : Array(String)
The cluster nodes parsed from the connection string.
-
#param(name : String) : String | Nil
Returns the first value for name from the connection string query.
- #params : URI::Params
- #password : String | Nil
- #ports : Array(Int32 | Nil)
-
#tls? : Bool
Whether the connection should be made over TLS.
- #username : String | Nil
Instance methods inherited from struct CryBase::Interfaces::ConnectionString
hosts : Array(String)
hosts,
initialize
initialize,
tls? : Bool
tls?
Constructor methods inherited from struct CryBase::Interfaces::ConnectionString
new
new
Constructor Detail
Parses input into a ConnectionString.
Raises ArgumentError if the string is empty or has no host
component.
ConnectionString.parse("localhost") # plaintext, no port
ConnectionString.parse("couchbases://h1,h2") # TLS, two hosts
Instance Method Detail
Reads a boolean query parameter. Accepted true values are true and
1; accepted false values are false and 0.
Port explicitly given in the URI, or nil when none was supplied.
Endpoint.from_string uses it for the selected endpoint. The
cluster-level Client uses it only for the Management endpoint.
The cluster nodes parsed from the connection string.
Returns the first value for name from the connection string query.
Whether the connection should be made over TLS.