Пример #1
0
    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)
Пример #2
0
 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)