forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(async): Making create app configurable (apache#25346)
- Loading branch information
1 parent
a971a28
commit 515452c
Showing
18 changed files
with
255 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
user nginx; | ||
worker_processes 1; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent [$connection_requests] "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
#tcp_nopush on; | ||
|
||
keepalive_timeout 30; | ||
keepalive_requests 2; | ||
|
||
###### Compression Stuff | ||
|
||
# Enable Gzip compressed. | ||
gzip on; | ||
|
||
# Compression level (1-9). | ||
# 5 is a perfect compromise between size and cpu usage, offering about | ||
# 75% reduction for most ascii files (almost identical to level 9). | ||
gzip_comp_level 5; | ||
|
||
# Don't compress anything that's already small and unlikely to shrink much | ||
# if at all (the default is 20 bytes, which is bad as that usually leads to | ||
# larger files after gzipping). | ||
gzip_min_length 256; | ||
|
||
# Compress data even for clients that are connecting to us via proxies, | ||
# identified by the "Via" header (required for CloudFront). | ||
gzip_proxied any; | ||
|
||
# Tell proxies to cache both the gzipped and regular version of a resource | ||
# whenever the client's Accept-Encoding capabilities header varies; | ||
# Avoids the issue where a non-gzip capable client (which is extremely rare | ||
# today) would display gibberish if their proxy gave them the gzipped version. | ||
gzip_vary on; | ||
|
||
# Compress all output labeled with one of the following MIME-types. | ||
gzip_types | ||
application/atom+xml | ||
application/javascript | ||
application/json | ||
application/rss+xml | ||
application/vnd.ms-fontobject | ||
application/x-font-ttf | ||
application/x-web-app-manifest+json | ||
application/xhtml+xml | ||
application/xml | ||
font/opentype | ||
image/svg+xml | ||
image/x-icon | ||
text/css | ||
text/plain | ||
text/x-component; | ||
# text/html is always compressed by HttpGzipModule | ||
|
||
output_buffers 20 10m; | ||
|
||
client_max_body_size 10m; | ||
|
||
upstream superset_app { | ||
server host.docker.internal:8088; | ||
keepalive 100; | ||
} | ||
|
||
upstream superset_websocket { | ||
server host.docker.internal:8080; | ||
keepalive 100; | ||
} | ||
|
||
server { | ||
listen 80 default_server; | ||
server_name _; | ||
|
||
location /ws { | ||
proxy_pass http://superset_websocket; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "Upgrade"; | ||
proxy_set_header Host $host; | ||
} | ||
|
||
location / { | ||
proxy_pass http://superset_app; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $remote_addr; | ||
proxy_set_header X-Forwarded-Host $host; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
proxy_http_version 1.1; | ||
port_in_redirect off; | ||
proxy_connect_timeout 300; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from flask import Flask | ||
|
||
from superset.async_events.async_query_manager import AsyncQueryManager | ||
from superset.utils.class_utils import load_class_from_name | ||
|
||
|
||
class AsyncQueryManagerFactory: | ||
def __init__(self) -> None: | ||
self._async_query_manager: AsyncQueryManager = None # type: ignore | ||
|
||
def init_app(self, app: Flask) -> None: | ||
self._async_query_manager = load_class_from_name( | ||
app.config["GLOBAL_ASYNC_QUERY_MANAGER_CLASS"] | ||
)() | ||
self._async_query_manager.init_app(app) | ||
|
||
def instance(self) -> AsyncQueryManager: | ||
return self._async_query_manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from importlib import import_module | ||
from typing import Any | ||
|
||
|
||
def load_class_from_name(fq_class_name: str) -> Any: | ||
""" | ||
Given a string representing a fully qualified class name, attempts to load | ||
the class and return it. | ||
:param fq_class_name: The fully qualified name of the class to load | ||
:return: The class object | ||
:raises Exception: if the class cannot be loaded | ||
""" | ||
if not fq_class_name: | ||
raise ValueError(f"Invalid class name {fq_class_name}") | ||
|
||
parts = fq_class_name.split(".") | ||
module_name = ".".join(parts[:-1]) | ||
class_name = parts[-1] | ||
|
||
module = import_module(module_name) | ||
return getattr(module, class_name) |
Oops, something went wrong.