class CryBase::CouchBase::Client

Overview

Cluster-level client that enumerates and probes every Couchbase service interface (KV, Query, Search, Analytics, Index, Eventing, Views, Management) for the configured hosts, over either plaintext or TLS ports.

No protocol handshake is performed at this layer — #connect only validates TCP reachability so callers can confirm the cluster's network surface before driving a service-specific protocol (for example CryBase::CouchBase::Services::KV::Client).

client = CryBase::CouchBase::Client.connect("couchbase://node1,node2")
kv_eps = client.endpoints_for(CryBase::CouchBase::Service::KV)
client.close

Defined in:

crybase/couchbase/client.cr

Constructors

Instance Method Summary

Instance methods inherited from class CryBase::Interfaces::Client

close : Nil close, connected? : Bool connected?, connection_string : ConnectionString connection_string

Constructor Detail

def self.connect(uri : String, username : String | Nil = nil, password : String | Nil = nil, connect_timeout : Time::Span = 5.seconds) : Client #

Builds the client and immediately calls #connect. Equivalent to new(...).tap(&.connect).

client = CryBase::CouchBase::Client.connect(
  "couchbases://node1,node2",
  username: "Administrator",
  password: "s3cret",
)

[View source]
def self.new(uri : String, username : String | Nil = nil, password : String | Nil = nil, connect_timeout : Time::Span = 5.seconds) #

Parses uri and pre-computes the full #endpoints matrix (one per host × service). No network activity yet.


[View source]

Instance Method Detail

def close : Nil #

Marks the client as no longer #connected?. This layer holds no persistent sockets, so this is purely a state flip.


[View source]
def connect : Array(Endpoint) #

Probes every endpoint over TCP and returns the reachable subset. Marks the client as #connected? if at least one endpoint responded; otherwise raises IO::Error.

reachable = client.connect # => [Endpoint, Endpoint, ...]

[View source]
def connect_timeout : Time::Span #

[View source]
def connected? : Bool #
Description copied from class CryBase::Interfaces::Client

Whether the client has completed a successful #connect.


[View source]
def connection_string : ConnectionString #
Description copied from class CryBase::Interfaces::Client

The parsed connection string the client was constructed from.


[View source]
def endpoints : Array(Endpoint) #

[View source]
def endpoints_for(service : Service) : Array(Endpoint) #

Returns every Endpoint for the given service, in host order.

client.endpoints_for(CryBase::CouchBase::Service::KV).map(&.host)
# => ["node1", "node2"]

[View source]
def password : String | Nil #

[View source]
def username : String | Nil #

[View source]