struct

CryBase::CouchBase::ConnectionString

Inherits CryBase::Interfaces::ConnectionString < Struct < Value < Object

Parses a Couchbase connection string of the form:

  • couchbase://host[,host2][:port] — plaintext
  • couchbases://host[,host2][:port] — TLS
  • couchbase://user:pass@host[:port]/bucket?params — credentials/options and default bucket
  • http(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"

Constructors

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, scheme : String = "couchbase")
Source
parse(input : String) : ConnectionString

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
Source

Instance methods

bool_param(name : String, default : Bool) : Bool

Reads a boolean query parameter. Accepted true values are true and 1; accepted false values are false and 0.

Source
bucket
Source
explicit_port

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.

Source
hosts

The cluster nodes parsed from the connection string.

Source
param(name : String) : String | Nil

Returns the first value for name from the connection string query.

Source
params
Source
password
Source
ports
Source
scheme
Source
tls?

Whether the connection should be made over TLS.

Source
username
Source