class CryBase::CouchBase::Services::KV::Cluster

Overview

Seed-failover KV client backed by one active KV::Pool.

Cluster accepts a multi-host Couchbase connection string, tries each seed host until one authenticated pool connects, and exposes the same document operation surface as KV::Pool.

This is not vbucket-map routing yet. It is a first cluster layer for seed failover; later routing can replace the single active pool with one pool per node.

cluster = KV::Cluster.from_string("couchbase://user:pass@n1,n2/default")
cluster.set("hello", "world")
cluster.close

Defined in:

crybase/couchbase/services/kv/cluster.cr

Constant Summary

DEFAULT_SIZE = Pool::DEFAULT_SIZE

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.from_string(uri : String, username : String | Nil = nil, password : String | Nil = nil, bucket : String | Nil = nil, size : Int32 = DEFAULT_SIZE, connect_timeout : Time::Span = 5.seconds, *, tls_verify : Bool | Nil = nil, tls_hostname : String | Nil = nil, tls_context : OpenSSL::SSL::Context::Client | Nil = nil) : Cluster #

Parses uri, builds KV seed endpoints for every host in the connection string, and connects to the first reachable/authenticated seed.

username, password, and #bucket may be passed explicitly or embedded as couchbase://user:pass@host1,host2/bucket.


[View source]
def self.new(seeds : Array(Endpoint), username : String, password : String, bucket : String, size : Int32 = DEFAULT_SIZE, connect_timeout : Time::Span = 5.seconds, *, tls_verify : Bool = true, tls_hostname : String | Nil = nil, tls_context : OpenSSL::SSL::Context::Client | Nil = nil) #

[View source]

Class Method Detail

def self.seed_endpoints(connection_string : ConnectionString) : Array(Endpoint) #

Builds one KV endpoint per seed host using the connection string's TLS mode and explicit port, when present.


[View source]

Instance Method Detail

def active_endpoint : Endpoint | Nil #

Returns the endpoint backing the current active pool, or nil if the cluster is closed before any pool was built.


[View source]
def bucket : String #

[View source]
def checkout(& : Client -> T) : T forall T #

[View source]
def close : Nil #

[View source]
def closed? : Bool #

[View source]
def decrement(*args, **kwargs) #

[View source]
def delete(*args, **kwargs) #

[View source]
def get(*args, **kwargs) #

[View source]
def get_as(*args, **kwargs) #

[View source]
def increment(*args, **kwargs) #

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

[View source]
def set(*args, **kwargs) #

[View source]
def size : Int32 #

[View source]
def touch(*args, **kwargs) #

[View source]