Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ WEBSERVER_PROJECTS={}
WEBSERVER_PROMETHEUS_API_VERSION=v1
WEBSERVER_PROMETHEUS_URL=http://prometheus:9090
WEBSERVER_PUBLICATIONS=1
WEBSERVER_REALTIME_COLLABORATION='{"RTC_MAX_NUMBER_OF_USERS":3}'
WEBSERVER_SCICRUNCH={}
WEBSERVER_SESSION_SECRET_KEY='REPLACE_ME_with_result__Fernet_generate_key='
WEBSERVER_SOCKETIO=1
Expand Down
1 change: 1 addition & 0 deletions services/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ services:
SWARM_STACK_NAME: ${SWARM_STACK_NAME}

WEBSERVER_DEV_FEATURES_ENABLED: ${WEBSERVER_DEV_FEATURES_ENABLED}
WEBSERVER_REALTIME_COLLABORATION: ${WEBSERVER_REALTIME_COLLABORATION}

WEBSERVER_LOGLEVEL: ${WEBSERVER_LOGLEVEL}
WEBSERVER_PROFILING: ${WEBSERVER_PROFILING}
Expand Down
4 changes: 2 additions & 2 deletions services/static-webserver/client/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ follow-dev-logs: ## follow the logs of the qx compiler
.PHONY: compile touch upgrade
compile: ## qx compiles host' 'source' -> image's 'build-output'
# qx compile 'source' within $(docker_image) image [itisfoundation/qooxdoo-kit:${QOOXDOO_KIT_TAG}]
@docker --debug buildx build \
@docker buildx build \
--load \
--file $(docker_file) \
--tag $(docker_image) \
Expand All @@ -58,7 +58,7 @@ compile: ## qx compiles host' 'source' -> image's 'build-output'

touch: ## minimal image build with /project/output-build inside
# touch /project/output-build such that multi-stage 'services/web/Dockerfile' can build development target (fixes #1097)
@docker --debug buildx build \
@docker buildx build \
--load \
--file $(docker_file) \
--tag $(docker_image) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

from aiohttp import web
from servicelib.aiohttp.application import create_safe_application
from simcore_service_webserver.collaboration.bootstrap import (
setup_realtime_collaboration,
)

from ._meta import WELCOME_DB_LISTENER_MSG, WELCOME_GC_MSG, WELCOME_MSG, info
from .activity.plugin import setup_activity
Expand Down Expand Up @@ -160,6 +163,7 @@ def create_application() -> web.Application:
setup_publications(app)
setup_studies_dispatcher(app)
setup_exporter(app)
setup_realtime_collaboration(app)

# NOTE: *last* events
app.on_startup.append(_welcome_banner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from ._meta import API_VERSION, API_VTAG, APP_NAME
from .catalog.settings import CatalogSettings
from .collaboration.settings import RealTimeCollaborationSettings
from .constants import APP_SETTINGS_KEY
from .diagnostics.settings import DiagnosticsSettings
from .director_v2.settings import DirectorV2Settings
Expand All @@ -55,7 +56,7 @@


# NOTE: to mark a plugin as a DEV-FEATURE annotated it with
# `Field(json_schema_extra={_X_DEV_FEATURE_FLAG: True})`
# `Field(json_schema_extra={_X_FEATURE_UNDER_DEVELOPMENT: True})`
# This will force it to be disabled when WEBSERVER_DEV_FEATURES_ENABLED=False
_X_FEATURE_UNDER_DEVELOPMENT: Final[str] = "x-dev-feature"

Expand Down Expand Up @@ -277,6 +278,17 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
Field(json_schema_extra={"auto_default_from_env": True}),
]

WEBSERVER_REALTIME_COLLABORATION: Annotated[
RealTimeCollaborationSettings | None,
Field(
description="Enables real-time collaboration features",
json_schema_extra={
"auto_default_from_env": True,
_X_FEATURE_UNDER_DEVELOPMENT: True,
},
),
]

WEBSERVER_REDIS: Annotated[
RedisSettings | None, Field(json_schema_extra={"auto_default_from_env": True})
]
Expand Down Expand Up @@ -482,6 +494,7 @@ def _get_disabled_advertised_plugins(self) -> list[str]:
"WEBSERVER_LICENSES",
"WEBSERVER_PAYMENTS",
"WEBSERVER_SCICRUNCH",
"WEBSERVER_REALTIME_COLLABORATION",
}
return [_ for _ in advertised_plugins if not self.is_enabled(_)] + [
# NOTE: Permanently retired in https://github.com/ITISFoundation/osparc-simcore/pull/7182
Expand Down Expand Up @@ -558,6 +571,9 @@ def to_client_statics(self) -> dict[str, Any]:
"WEBSERVER_PROJECTS": {
"PROJECTS_MAX_NUM_RUNNING_DYNAMIC_NODES",
},
"WEBSERVER_REALTIME_COLLABORATION": {
"RTC_MAX_NUMBER_OF_USERS",
},
"WEBSERVER_SESSION": {"SESSION_COOKIE_MAX_AGE"},
"WEBSERVER_TRASH": {
"TRASH_RETENTION_DAYS",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import logging

from aiohttp import web
from servicelib.aiohttp.application_setup import ModuleCategory, app_module_setup

_logger = logging.getLogger(__name__)


@app_module_setup(
__name__,
ModuleCategory.ADDON,
settings_name="WEBSERVER_REALTIME_COLLABORATION",
logger=_logger,
)
def setup_realtime_collaboration(app: web.Application):
from .settings import get_plugin_settings

assert get_plugin_settings(app), "setup_settings not called?"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from typing import Annotated

from aiohttp import web
from pydantic import (
PositiveInt,
)
from pydantic.fields import Field
from settings_library.base import BaseCustomSettings

from ..constants import APP_SETTINGS_KEY


class RealTimeCollaborationSettings(BaseCustomSettings):
RTC_MAX_NUMBER_OF_USERS: Annotated[
PositiveInt,
Field(
description="Maximum number of users allowed in a real-time collaboration session",
),
]


def get_plugin_settings(app: web.Application) -> RealTimeCollaborationSettings:
settings = app[APP_SETTINGS_KEY].WEBSERVER_REALTIME_COLLABORATION
assert settings, "setup_settings not called?" # nosec
assert isinstance(settings, RealTimeCollaborationSettings) # nosec
return settings
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def test_settings_to_client_statics(app_settings: ApplicationSettings):
def test_settings_to_client_statics_plugins(
mock_webserver_service_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch
):
monkeypatch.delenv("WEBSERVER_REALTIME_COLLABORATION", raising=False)

# explicitly disable these plugins
disable_plugins = {
"WEBSERVER_EXPORTER",
"WEBSERVER_SCICRUNCH",
Expand All @@ -82,12 +85,21 @@ def test_settings_to_client_statics_plugins(
for name in disable_plugins:
monkeypatch.setenv(name, "null")

# explicitly disable WEBSERVER_FOLDERS
monkeypatch.setenv("WEBSERVER_FOLDERS", "0")
disable_plugins.add("WEBSERVER_FOLDERS")

# set WEBSERVER_REALTIME_COLLABORATION (NOTE: for now WEBSERVER_DEV_FEATURES_ENABLED=True) )
monkeypatch.setenv(
"WEBSERVER_REALTIME_COLLABORATION", '{"RTC_MAX_NUMBER_OF_USERS":3}'
)

settings = ApplicationSettings.create_from_envs()
statics = settings.to_client_statics()
assert settings.WEBSERVER_DEV_FEATURES_ENABLED

# -------------

statics = settings.to_client_statics()
print("STATICS:\n", json_dumps(statics, indent=1))

assert settings.WEBSERVER_LOGIN
Expand All @@ -111,6 +123,15 @@ def test_settings_to_client_statics_plugins(
assert statics["vcsReleaseTag"]
assert TypeAdapter(HttpUrl).validate_python(statics["vcsReleaseUrl"])

# check WEBSERVER_REALTIME_COLLABORATION enabled
assert "WEBSERVER_REALTIME_COLLABORATION" not in statics["pluginsDisabled"]
assert settings.WEBSERVER_REALTIME_COLLABORATION
assert (
statics["webserverRealtimeCollaboration"]["RTC_MAX_NUMBER_OF_USERS"]
== settings.WEBSERVER_REALTIME_COLLABORATION.RTC_MAX_NUMBER_OF_USERS
)

# check disabled plugins
assert set(statics["pluginsDisabled"]) == (disable_plugins)


Expand Down
Loading