-
Notifications
You must be signed in to change notification settings - Fork 30
✨payments
service: notification of payments to the front-end via socketio
#5057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pcrespov
merged 23 commits into
ITISFoundation:master
from
pcrespov:is4657/enh-one-time-payment
Nov 29, 2023
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ddc3b04
adds sio to requirements
pcrespov 8a16f03
drafts setup and tests
pcrespov c5220c1
WIP: sio
pcrespov 5868399
minor
pcrespov 14a4c91
WIP
pcrespov a538509
delay response and common socketio model
pcrespov a0995e2
WIP
pcrespov fc2e249
socketio utils
pcrespov d563721
cleanup test
pcrespov 2a1ef78
updates tests
pcrespov ac4f59f
fixes test
pcrespov 9e11756
updates fake gateway
pcrespov 721b615
fixes patch
pcrespov a30122a
adds as ascript
pcrespov 5a44eb0
refactor
pcrespov 58130c2
fixes test
pcrespov 421483c
cleanup
pcrespov 556d620
fixes on_payment_completed
pcrespov 43b8be2
cleanup on_completed
pcrespov e0f3c9a
creates notifier
pcrespov dee7ebb
cc
pcrespov 7417cff
@GitHK review: doc and rm comments
pcrespov 453d955
rm cc
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
4 changes: 4 additions & 0 deletions
4
packages/models-library/src/models_library/api_schemas_payments/socketio.py
This file contains hidden or 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,4 @@ | ||
from typing import Final | ||
|
||
SOCKET_IO_PAYMENT_COMPLETED_EVENT: Final[str] = "paymentCompleted" | ||
SOCKET_IO_PAYMENT_METHOD_ACKED_EVENT: Final[str] = "paymentMethodAcknoledged" |
This file contains hidden or 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 typing import Any, TypedDict | ||
|
||
|
||
class SocketMessageDict(TypedDict): | ||
event_type: str | ||
data: dict[str, Any] |
This file contains hidden or 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,43 @@ | ||
""" Common utilities for python-socketio library | ||
|
||
|
||
NOTE: we intentionally avoided importing socketio here to avoid adding an extra dependency at | ||
this level which would include python-socketio in all libraries | ||
""" | ||
|
||
import asyncio | ||
|
||
|
||
async def cleanup_socketio_async_pubsub_manager(server_manager): | ||
|
||
# NOTE: this is ugly. It seems though that python-socketio does not | ||
# cleanup its background tasks properly. | ||
# https://github.com/miguelgrinberg/python-socketio/discussions/1092 | ||
cancelled_tasks = [] | ||
|
||
if hasattr(server_manager, "thread"): | ||
server_thread = server_manager.thread | ||
assert isinstance(server_thread, asyncio.Task) # nosec | ||
server_thread.cancel() | ||
cancelled_tasks.append(server_thread) | ||
|
||
if server_manager.publisher_channel: | ||
await server_manager.publisher_channel.close() | ||
|
||
if server_manager.publisher_connection: | ||
await server_manager.publisher_connection.close() | ||
|
||
current_tasks = asyncio.tasks.all_tasks() | ||
for task in current_tasks: | ||
coro = task.get_coro() | ||
if any( | ||
coro_name in coro.__qualname__ # type: ignore | ||
for coro_name in [ | ||
"AsyncServer._service_task", | ||
"AsyncSocket.schedule_ping", | ||
"AsyncPubSubManager._thread", | ||
] | ||
): | ||
task.cancel() | ||
cancelled_tasks.append(task) | ||
await asyncio.gather(*cancelled_tasks, return_exceptions=True) | ||
pcrespov marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.