struct CryBase::CouchBase::ConnectionString

Overview

Parses a Couchbase connection string of the form:

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.cr

Constructors

Instance Method Summary

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

def self.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) #

[View source]
def self.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

[View source]

Instance Method Detail

def 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.


[View source]
def bucket : String | Nil #

[View source]
def explicit_port : Int32 | Nil #

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.


[View source]
def hosts : Array(String) #
Description copied from struct CryBase::Interfaces::ConnectionString

The cluster nodes parsed from the connection string.


[View source]
def param(name : String) : String | Nil #

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


[View source]
def params : URI::Params #

[View source]
def password : String | Nil #

[View source]
def ports : Array(Int32 | Nil) #

[View source]
def tls? : Bool #
Description copied from struct CryBase::Interfaces::ConnectionString

Whether the connection should be made over TLS.


[View source]
def username : String | Nil #

[View source]