def __init__(self, uri, **config): self.initial_address = initial_address = SocketAddress.from_uri( uri, DEFAULT_PORT) self.security_plan = security_plan = SecurityPlan.build(**config) self.encrypted = security_plan.encrypted routing_context = SocketAddress.parse_routing_context(uri) if not security_plan.routing_compatible: # this error message is case-specific as there is only one incompatible # scenario right now raise ValueError( "TRUST_ON_FIRST_USE is not compatible with routing") def connector(address, error_handler): return connect(address, security_plan.ssl_context, error_handler, **config) pool = RoutingConnectionPool(connector, initial_address, routing_context, initial_address, **config) try: pool.update_routing_table() except: pool.close() raise else: Driver.__init__(self, pool, **config)
def __new__(cls, uri, **config): cls._check_uri(uri) if SocketAddress.parse_routing_context(uri): raise ValueError( "Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri) instance = object.__new__(cls) # We keep the address containing the host name or IP address exactly # as-is from the original URI. This means that every new connection # will carry out DNS resolution, leading to the possibility that # the connection pool may contain multiple IP address keys, one for # an old address and one for a new address. instance.address = SocketAddress.from_uri(uri, DEFAULT_PORT) instance.security_plan = security_plan = SecurityPlan.build(**config) instance.encrypted = security_plan.encrypted def connector(address, error_handler): return connect(address, security_plan.ssl_context, error_handler, **config) pool = DirectConnectionPool(connector, instance.address, **config) pool.release(pool.acquire()) instance._pool = pool instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"]) return instance
def __new__(cls, uri, **config): cls._check_uri(uri) instance = object.__new__(cls) instance.initial_address = initial_address = SocketAddress.from_uri( uri, DEFAULT_PORT) instance.security_plan = security_plan = SecurityPlan.build(**config) instance.encrypted = security_plan.encrypted routing_context = SocketAddress.parse_routing_context(uri) if not security_plan.routing_compatible: # this error message is case-specific as there is only one incompatible # scenario right now raise ValueError( "TRUST_ON_FIRST_USE is not compatible with routing") def connector(address, error_handler): return connect(address, security_plan.ssl_context, error_handler, **config) pool = RoutingConnectionPool(connector, initial_address, routing_context, initial_address, **config) try: pool.update_routing_table() except: pool.close() raise else: instance._pool = pool instance._max_retry_time = config.get( "max_retry_time", default_config["max_retry_time"]) return instance
def load(result): from neo4j.v1 import BoltStatementResultSummary keys = self._keys = self._hydrant.keys = tuple(result["columns"]) hydrate = self._hydrant.hydrate for record in result["data"]: self._records.append(Record(zip(keys, hydrate(record["rest"])))) stats = result["stats"] # fix broken key if "relationship_deleted" in stats: stats["relationships_deleted"] = stats["relationship_deleted"] del stats["relationship_deleted"] if "contains_updates" in stats: del stats["contains_updates"] metadata = {"stats": stats} if "plan" in result: metadata["http_plan"] = result["plan"] # TODO: fill these in metadata["statement"] = None metadata["parameters"] = None metadata["server"] = ServerInfo(SocketAddress.from_uri(session.graph.database.uri)) self._summary = BoltStatementResultSummary(**metadata) self._session = None return len(self._records)
def __init__(self, uri, **config): # We keep the address containing the host name or IP address exactly # as-is from the original URI. This means that every new connection # will carry out DNS resolution, leading to the possibility that # the connection pool may contain multiple IP address keys, one for # an old address and one for a new address. if SocketAddress.parse_routing_context(uri): raise ValueError("Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri) self.address = SocketAddress.from_uri(uri, DEFAULT_PORT) self.security_plan = security_plan = SecurityPlan.build(**config) self.encrypted = security_plan.encrypted pool = DirectConnectionPool(lambda a: connect(a, security_plan.ssl_context, **config), self.address) pool.release(pool.acquire()) Driver.__init__(self, pool, **config)