struct CryBase::CouchBase::Endpoint

Overview

A single addressable Couchbase service interface — the combination of a host, a port, the Service running on that port, and whether the connection should be TLS.

ep = CryBase::CouchBase::Endpoint.new("h1", 11210, CryBase::CouchBase::Service::KV, false)
ep.scheme  # => "couchbase"
ep.address # => "couchbase://h1:11210"
ep.to_s    # => "Data (KV) couchbase://h1:11210"

Defined in:

crybase/couchbase/endpoint.cr

Constructors

Instance Method Summary

Instance methods inherited from struct CryBase::Interfaces::Endpoint

host : String host, initialize initialize, port : Int32 port, tls? : Bool tls?

Constructor methods inherited from struct CryBase::Interfaces::Endpoint

new new

Constructor Detail

def self.from_string(input : String, service : Service | Nil = nil) : Endpoint #

Parses a connection string and returns one concrete endpoint for the first host.

Pass service to choose a specific Couchbase service. When omitted, couchbase:// and couchbases:// strings produce a KV endpoint, while http:// and https:// strings produce a Management endpoint. An explicit port in the string overrides the selected service's default port.

Endpoint.from_string("couchbase://node1").address              # => "couchbase://node1:11210"
Endpoint.from_string("couchbases://node1:11217").port          # => 11217
Endpoint.from_string("https://node1:18091").service            # => Service::Management
Endpoint.from_string("couchbase://node1", Service::Query).port # => 8093

[View source]
def self.new(host : String, port : Int32, service : Service, tls : Bool) #

[View source]

Instance Method Detail

def address : String #

Full scheme://host:port string for this endpoint.

Endpoint.new("host", 11210, Service::KV, false).address # => "couchbase://host:11210"

[View source]
def host : String #

[View source]
def port : Int32 #

[View source]
def scheme : String #

The URI scheme appropriate for this endpoint:

  • "couchbase" / "couchbases" for the KV service
  • "http" / "https" for every other service
Endpoint.new("host", 11210, Service::KV, false).scheme   # => "couchbase"
Endpoint.new("host", 11207, Service::KV, true).scheme    # => "couchbases"
Endpoint.new("host", 8093, Service::Query, false).scheme # => "http"

[View source]
def service : Service #

[View source]
def tls? : Bool #

[View source]
def to_s(io : IO) : Nil #

Renders the endpoint as "<service display name> <address>".

Endpoint.new("host", 11210, Service::KV, false).to_s # => "Data (KV) couchbase://host:11210"

[View source]