struct

CryBase::CouchBase::Endpoint

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

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"

Constructors

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
Source
new(host : String, port : Int32, service : Service, tls : Bool)
Source

Instance methods

address

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

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

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"
Source
service
Source
tls?
Source
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"
Source