Class: Neo4j::Driver::Routing::ServerAddress
- Inherits:
-
Object
- Object
- Neo4j::Driver::Routing::ServerAddress
- Defined in:
- lib/neo4j/driver/routing/server_address.rb
Overview
Host:port pair for a single Bolt server. Hashable so it works as a key in the LoadBalancer's per-server pool map.
Constant Summary collapse
- DEFAULT_PORT =
7687
Class Method Summary collapse
-
.parse(string) ⇒ Object
Parse "host:port" or "[ipv6]:port" (or bare "host" → default port).
Instance Method Summary collapse
Class Method Details
.parse(string) ⇒ Object
Parse "host:port" or "[ipv6]:port" (or bare "host" → default port).
12 13 14 15 16 17 |
# File 'lib/neo4j/driver/routing/server_address.rb', line 12 def self.parse(string) host, sep, port = string.to_s.rpartition(':') return new(host: string.to_s, port: DEFAULT_PORT) if sep.empty? new(host: host, port: Integer(port)) end |
Instance Method Details
#to_s ⇒ Object
19 20 21 |
# File 'lib/neo4j/driver/routing/server_address.rb', line 19 def to_s host.include?(':') && !host.start_with?('[') ? "[#{host}]:#{port}" : "#{host}:#{port}" end |