def __init__(self, nethost: str, netport: int, database: str, user: str, concurrency: int, protocol: str, **kwargs): super().__init__(**kwargs) if protocol != self.get_proto_name(): raise RuntimeError(f'unknown protocol {protocol!r}') if concurrency <= 0 or concurrency > defines.HTTP_PORT_MAX_CONCURRENCY: raise RuntimeError( f'concurrency must be greater than 0 and ' f'less than {defines.HTTP_PORT_MAX_CONCURRENCY}') self._compilers = asyncio.LifoQueue() self._pgcons = asyncio.LifoQueue() self._compilers_list = [] self._pgcons_list = [] self._nethost = nethost self._netport = netport self.database = database self.user = user self.concurrency = concurrency self._servers = [] self._query_cache = cache.StatementsCache( maxsize=defines.HTTP_PORT_QUERY_CACHE_SIZE)
def __init__(self, nethost: str, netport: int, database: str, user: str, concurrency: int, protocol: str, **kwargs): super().__init__(**kwargs) self._compiler_pool_size = 0 if protocol != self.get_proto_name(): raise RuntimeError(f'unknown protocol {protocol!r}') if concurrency <= 0 or concurrency > defines.HTTP_PORT_MAX_CONCURRENCY: raise RuntimeError( f'concurrency must be greater than 0 and ' f'less than {defines.HTTP_PORT_MAX_CONCURRENCY}') self._compilers: asyncio.LifoQueue[Any] = asyncio.LifoQueue() self._compilers_list: List[Any] = [] self._nethost = nethost self._netport = netport self.database = database self.user = user self.concurrency = concurrency self.last_minute_requests = windowedsum.WindowedSum() self._http_proto_server = None self._http_request_logger = None self._query_cache = cache.StatementsCache( maxsize=defines.HTTP_PORT_QUERY_CACHE_SIZE)
def __init__( self, *, loop, cluster, runstate_dir, internal_runstate_dir, max_backend_connections, compiler_pool_size, nethost, netport, auto_shutdown: bool = False, echo_runtime_info: bool = False, status_sink: Optional[Callable[[str], None]] = None, startup_script: Optional[srvargs.StartupScript] = None, ): self._loop = loop # Used to tag PG notifications to later disambiguate them. self._server_id = str(uuid.uuid4()) self._serving = False self._initing = False self._cluster = cluster self._pg_addr = self._get_pgaddr() inst_params = cluster.get_runtime_params().instance_params self._tenant_id = inst_params.tenant_id # 1 connection is reserved for the system DB pool_capacity = max_backend_connections - 1 self._pg_pool = connpool.Pool( connect=self._pg_connect, disconnect=self._pg_disconnect, max_capacity=pool_capacity, ) # DB state will be initialized in init(). self._dbindex = None self._runstate_dir = runstate_dir self._internal_runstate_dir = internal_runstate_dir self._max_backend_connections = max_backend_connections self._compiler_pool_size = compiler_pool_size self._listen_host = nethost self._listen_port = netport self._sys_auth: Tuple[Any, ...] = tuple() # Shutdown the server after the last management # connection has disconnected self._auto_shutdown = auto_shutdown self._echo_runtime_info = echo_runtime_info self._status_sink = status_sink self._startup_script = startup_script # Never use `self.__sys_pgcon` directly; get it via # `await self._acquire_sys_pgcon()`. self.__sys_pgcon = None self._roles = immutables.Map() self._instance_data = immutables.Map() self._sys_queries = immutables.Map() self._devmode = devmode.is_in_dev_mode() self._binary_proto_id_counter = 0 self._binary_proto_num_connections = 0 self._accepting_connections = False self._servers = [] self._http_query_cache = cache.StatementsCache( maxsize=defines.HTTP_PORT_QUERY_CACHE_SIZE) self._http_last_minute_requests = windowedsum.WindowedSum() self._http_request_logger = None