-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add auth and expose rpc server sidecar (#762)
Co-authored-by: Rok Roškar <roskarr@ethz.ch>
- Loading branch information
Showing
13 changed files
with
744 additions
and
167 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
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,42 @@ | ||
import os | ||
from urllib.parse import urljoin | ||
|
||
from flask import Flask | ||
from jsonrpc.backend.flask import api, Blueprint | ||
|
||
from git_services.sidecar.rpc_server import autosave, status | ||
from git_services.sidecar.config import config_from_env | ||
|
||
|
||
def health_endpoint(): | ||
"""Health endpoint for probes.""" | ||
return {"status": "running"} | ||
|
||
|
||
def get_app(): | ||
"""Setup flask app""" | ||
os.environ["RUNNING_WITH_GEVENT"] = "true" | ||
config = config_from_env() | ||
app = Flask(__name__) | ||
health_bp = Blueprint("health", __name__) | ||
health_bp.route("/")(health_endpoint) | ||
jsonrpc_bp = api.as_blueprint() | ||
api.dispatcher.add_method(status, "git/get_status") | ||
api.dispatcher.add_method(autosave, "autosave/create") | ||
app.register_blueprint(jsonrpc_bp, url_prefix=urljoin(config.url_prefix, "jsonrpc")) | ||
app.register_blueprint(health_bp, url_prefix=urljoin(config.url_prefix, "health")) | ||
|
||
if config.sentry.enabled: | ||
import sentry_sdk | ||
from sentry_sdk.integrations.flask import FlaskIntegration | ||
|
||
sentry_sdk.init( | ||
dsn=config.sentry.dsn, | ||
environment=config.sentry.environment, | ||
integrations=[FlaskIntegration()], | ||
traces_sample_rate=config.sentry.sample_rate, | ||
) | ||
return app | ||
|
||
|
||
app = get_app() |
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,6 @@ | ||
from git_services.sidecar.config import config_from_env | ||
|
||
_config = config_from_env() | ||
bind = f"{_config.host}:{_config.port}" | ||
wsgi_app = "git_services.sidecar.app:app" | ||
worker_class = "gevent" |
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
Oops, something went wrong.