-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Connects webserver and payments service (#4886)
- Loading branch information
Showing
21 changed files
with
303 additions
and
328 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from typing import Final | ||
|
||
from pydantic import parse_obj_as | ||
|
||
from ..rabbitmq_basic_types import RPCNamespace | ||
|
||
PAYMENTS_RPC_NAMESPACE: Final[RPCNamespace] = parse_obj_as(RPCNamespace, "payments") |
21 changes: 21 additions & 0 deletions
21
packages/models-library/src/models_library/rabbitmq_basic_types.py
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,21 @@ | ||
import re | ||
from typing import Final | ||
|
||
from pydantic import ConstrainedStr, parse_obj_as | ||
|
||
REGEX_RABBIT_QUEUE_ALLOWED_SYMBOLS: Final[str] = r"^[\w\-\.]*$" | ||
|
||
|
||
class RPCNamespace(ConstrainedStr): | ||
min_length: int = 1 | ||
max_length: int = 252 | ||
regex: re.Pattern[str] | None = re.compile(REGEX_RABBIT_QUEUE_ALLOWED_SYMBOLS) | ||
|
||
@classmethod | ||
def from_entries(cls, entries: dict[str, str]) -> "RPCNamespace": | ||
""" | ||
Given a list of entries creates a namespace to be used in declaring the rabbitmq queue. | ||
Keeping this to a predefined length | ||
""" | ||
composed_string = "-".join(f"{k}_{v}" for k, v in sorted(entries.items())) | ||
return parse_obj_as(cls, composed_string) |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
from typing import Final | ||
|
||
BIND_TO_ALL_TOPICS: Final[str] = "#" | ||
REGEX_RABBIT_QUEUE_ALLOWED_SYMBOLS: Final[str] = r"^[\w\-\.]*$" |
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
15 changes: 4 additions & 11 deletions
15
services/payments/src/simcore_service_payments/api/rpc/routes.py
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 |
---|---|---|
@@ -1,24 +1,17 @@ | ||
import logging | ||
from typing import Final | ||
|
||
from fastapi import FastAPI | ||
from pydantic import parse_obj_as | ||
from servicelib.rabbitmq import RPCNamespace | ||
from models_library.api_schemas_payments import PAYMENTS_RPC_NAMESPACE | ||
|
||
from ...services.rabbitmq import get_rabbitmq_rpc_client, is_rabbitmq_enabled | ||
from ...services.rabbitmq import get_rabbitmq_rpc_server | ||
from . import _payments | ||
|
||
_logger = logging.getLogger(__name__) | ||
|
||
PAYMENTS_RPC_NAMESPACE: Final[RPCNamespace] = parse_obj_as(RPCNamespace, "payments") | ||
|
||
|
||
def setup_rpc_api_routes(app: FastAPI) -> None: | ||
async def _on_startup() -> None: | ||
if is_rabbitmq_enabled(app): | ||
rpc_client = get_rabbitmq_rpc_client(app) | ||
await rpc_client.register_router( | ||
_payments.router, PAYMENTS_RPC_NAMESPACE, app | ||
) | ||
rpc_server = get_rabbitmq_rpc_server(app) | ||
await rpc_server.register_router(_payments.router, PAYMENTS_RPC_NAMESPACE, app) | ||
|
||
app.add_event_handler("startup", _on_startup) |
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
135 changes: 0 additions & 135 deletions
135
services/web/server/src/simcore_service_webserver/payments/_client.py
This file was deleted.
Oops, something went wrong.
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.