Skip to content
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

♻️ servicelib.fastapi tools and rabbitmq.rpc errors interface #5157

Merged
merged 17 commits into from
Dec 12, 2023

Conversation

pcrespov
Copy link
Member

@pcrespov pcrespov commented Dec 11, 2023

What do these changes do?

♻️ fastapi tools

Separation of policies so they can be combined at will (and not imposed from a base class)

  • app_state.AppStateMixin: to create/get/delete a single instance of a class in the app.state
  • http_client:
    • wrapper to httpx.AsyncClient to bind lifespan of the wrapped client to the app
    • In a separate PR, we will split healthcheck mixin with liveness probes and readyness probes
  • httpx_utils: free functions on httpx interface

✨ RPC errors interface

Allows raising selection of exceptions in rpc (similar to https://tenacity.readthedocs.io/en/latest/#whether-to-retry)

  • common error interface : moves common payments exceptions models_library.api_schemas_payments.errors.
  • rpc-server interface: define in server side which exceptions are "expected": set in payments.api.rpc interface: this way interface includes not only functionality but expected errors.
  • plugin to http error: now payments plugin will raise in the rpc calls the exceptions above and are handled accordingly in the rest calls. Note that the rest has yet another error handling mechanism that translates these exceptions to http errors. SEE wallets._handlers.handle_wallets_exceptions)
  • These are the diffrent errors
    • _BaseAppError: internal to payments service
    • PaymentsPluginError: internal to payments plugin in webserver
    • _BaseRpcApiError subclasses: shared by RPC server(in payments service) and client (in web-server service)

🐛 fixes a bug that affect "FAKE" mode

  • used for development i.e. inconvenient but not critical
  • adds more logs for fake mode

Related issue/s

How to test

see new driving tests files

Dev Checklist

DevOps

  • Title added in .env-devel I will also add it in the repo.configs. This is a way to clarify which env I am using when I have symbolic links to them

Copy link

codecov bot commented Dec 11, 2023

Codecov Report

Merging #5157 (1ef7214) into master (09dd712) will decrease coverage by 0.3%.
The diff coverage is 84.3%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #5157     +/-   ##
========================================
- Coverage    87.4%   87.1%   -0.3%     
========================================
  Files        1277    1164    -113     
  Lines       52422   50065   -2357     
  Branches     1133     928    -205     
========================================
- Hits        45836   43630   -2206     
+ Misses       6346    6227    -119     
+ Partials      240     208     -32     
Flag Coverage Δ
integrationtests 63.5% <58.3%> (-1.4%) ⬇️
unittests 85.0% <84.3%> (-0.3%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...ervice-library/src/servicelib/fastapi/app_state.py 100.0% <100.0%> (ø)
...vice-library/src/servicelib/fastapi/http_client.py 85.7% <ø> (-5.4%) ⬇️
...ice-library/src/servicelib/rabbitmq/_client_rpc.py 96.8% <100.0%> (+<0.1%) ⬆️
...vice-library/src/servicelib/rabbitmq/_constants.py 100.0% <100.0%> (ø)
...ore_service_payments/api/rest/_acknowledgements.py 94.5% <100.0%> (ø)
...simcore_service_payments/api/rest/_dependencies.py 100.0% <100.0%> (ø)
.../src/simcore_service_payments/api/rpc/_payments.py 100.0% <100.0%> (ø)
...core_service_payments/api/rpc/_payments_methods.py 100.0% <100.0%> (ø)
.../simcore_service_payments/db/auto_recharge_repo.py 74.2% <100.0%> (ø)
...mcore_service_payments/db/payments_methods_repo.py 87.5% <100.0%> (ø)
... and 14 more

... and 128 files with indirect coverage changes

@pcrespov pcrespov self-assigned this Dec 11, 2023
@pcrespov pcrespov changed the title WIP: ♻️ servicelib.fastapi and rabbitmq.rpc tooling ♻️ servicelib.fastapi and rabbitmq.rpc tooling Dec 11, 2023
@pcrespov pcrespov added a:services-library issues on packages/service-libs a:payments payments service labels Dec 11, 2023
@pcrespov pcrespov added this to the Kobayashi Maru milestone Dec 11, 2023
@pcrespov pcrespov marked this pull request as ready for review December 11, 2023 16:38
@pcrespov pcrespov changed the title ♻️ servicelib.fastapi and rabbitmq.rpc tooling ♻️ servicelib.fastapi tooling and rabbitmq.rpc errors interface Dec 11, 2023
@pcrespov pcrespov changed the title ♻️ servicelib.fastapi tooling and rabbitmq.rpc errors interface ♻️ servicelib.fastapi tools and rabbitmq.rpc errors interface Dec 11, 2023
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! thanks!

Copy link
Contributor

@GitHK GitHK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look good to me

@pcrespov pcrespov enabled auto-merge (squash) December 11, 2023 17:39
Copy link
Contributor

@matusdrobuliak66 matusdrobuliak66 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!!

Copy link
Contributor

@bisgaard-itis bisgaard-itis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! Thanks a lot

Copy link

codeclimate bot commented Dec 12, 2023

Code Climate has analyzed commit 1ef7214 and detected 0 issues on this pull request.

View more on Code Climate.

Copy link

sonarcloud bot commented Dec 12, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@pcrespov pcrespov merged commit 535f59d into ITISFoundation:master Dec 12, 2023
56 checks passed
@pcrespov pcrespov deleted the enh/servicelib branch December 12, 2023 13:47
@matusdrobuliak66 matusdrobuliak66 mentioned this pull request Jan 8, 2024
33 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:payments payments service a:services-library issues on packages/service-libs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants