orsa 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. orsa-0.1.1/.gitattributes +63 -0
  2. orsa-0.1.1/.github/workflows/python-publish.yml +101 -0
  3. orsa-0.1.1/.gitignore +364 -0
  4. orsa-0.1.1/LICENSE.txt +21 -0
  5. orsa-0.1.1/PKG-INFO +104 -0
  6. orsa-0.1.1/README.md +85 -0
  7. orsa-0.1.1/examples/_1_sample_saga.py +40 -0
  8. orsa-0.1.1/examples/_2_rollback_saga.py +58 -0
  9. orsa-0.1.1/examples/_3_sample_saga_manager.py +41 -0
  10. orsa-0.1.1/examples/bcb9e32f-1c39-4b53-9758-dd9f89b6b96c +1 -0
  11. orsa-0.1.1/examples/examples.py +33 -0
  12. orsa-0.1.1/examples/examples.pyproj +52 -0
  13. orsa-0.1.1/examples/saga.db.json +1 -0
  14. orsa-0.1.1/examples/shared/__init__.py +1 -0
  15. orsa-0.1.1/examples/shared/manager.py +72 -0
  16. orsa-0.1.1/examples/shared/ordering.py +51 -0
  17. orsa-0.1.1/examples/shared/otypes.py +13 -0
  18. orsa-0.1.1/orsa/__init__.py +15 -0
  19. orsa-0.1.1/orsa/context/__init__.py +1 -0
  20. orsa-0.1.1/orsa/context/_async.py +59 -0
  21. orsa-0.1.1/orsa/core/__init__.py +3 -0
  22. orsa-0.1.1/orsa/core/_callee.py +80 -0
  23. orsa-0.1.1/orsa/core/_context.py +136 -0
  24. orsa-0.1.1/orsa/core/_logger.py +41 -0
  25. orsa-0.1.1/orsa/core/_manager.py +206 -0
  26. orsa-0.1.1/orsa/core/_orchestrator.py +39 -0
  27. orsa-0.1.1/orsa/core/_types.py +29 -0
  28. orsa-0.1.1/orsa/orsa.pyproj +56 -0
  29. orsa-0.1.1/orsa.egg-info/PKG-INFO +104 -0
  30. orsa-0.1.1/orsa.egg-info/SOURCES.txt +34 -0
  31. orsa-0.1.1/orsa.egg-info/dependency_links.txt +1 -0
  32. orsa-0.1.1/orsa.egg-info/requires.txt +1 -0
  33. orsa-0.1.1/orsa.egg-info/top_level.txt +1 -0
  34. orsa-0.1.1/pyproject.toml +30 -0
  35. orsa-0.1.1/saga-orchestrator.slnx +12 -0
  36. orsa-0.1.1/setup.cfg +4 -0
@@ -0,0 +1,63 @@
1
+ ###############################################################################
2
+ # Set default behavior to automatically normalize line endings.
3
+ ###############################################################################
4
+ * text=auto
5
+
6
+ ###############################################################################
7
+ # Set default behavior for command prompt diff.
8
+ #
9
+ # This is need for earlier builds of msysgit that does not have it on by
10
+ # default for csharp files.
11
+ # Note: This is only used by command line
12
+ ###############################################################################
13
+ #*.cs diff=csharp
14
+
15
+ ###############################################################################
16
+ # Set the merge driver for project and solution files
17
+ #
18
+ # Merging from the command prompt will add diff markers to the files if there
19
+ # are conflicts (Merging from VS is not affected by the settings below, in VS
20
+ # the diff markers are never inserted). Diff markers may cause the following
21
+ # file extensions to fail to load in VS. An alternative would be to treat
22
+ # these files as binary and thus will always conflict and require user
23
+ # intervention with every merge. To do so, just uncomment the entries below
24
+ ###############################################################################
25
+ #*.sln merge=binary
26
+ #*.csproj merge=binary
27
+ #*.vbproj merge=binary
28
+ #*.vcxproj merge=binary
29
+ #*.vcproj merge=binary
30
+ #*.dbproj merge=binary
31
+ #*.fsproj merge=binary
32
+ #*.lsproj merge=binary
33
+ #*.wixproj merge=binary
34
+ #*.modelproj merge=binary
35
+ #*.sqlproj merge=binary
36
+ #*.wwaproj merge=binary
37
+
38
+ ###############################################################################
39
+ # behavior for image files
40
+ #
41
+ # image files are treated as binary by default.
42
+ ###############################################################################
43
+ #*.jpg binary
44
+ #*.png binary
45
+ #*.gif binary
46
+
47
+ ###############################################################################
48
+ # diff behavior for common document formats
49
+ #
50
+ # Convert binary document formats to text before diffing them. This feature
51
+ # is only available from the command line. Turn it on by uncommenting the
52
+ # entries below.
53
+ ###############################################################################
54
+ #*.doc diff=astextplain
55
+ #*.DOC diff=astextplain
56
+ #*.docx diff=astextplain
57
+ #*.DOCX diff=astextplain
58
+ #*.dot diff=astextplain
59
+ #*.DOT diff=astextplain
60
+ #*.pdf diff=astextplain
61
+ #*.PDF diff=astextplain
62
+ #*.rtf diff=astextplain
63
+ #*.RTF diff=astextplain
@@ -0,0 +1,101 @@
1
+ name: Upload Python Package
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*'
7
+ - 'v*.*'
8
+ release:
9
+ types: [created]
10
+ workflow_dispatch:
11
+ inputs:
12
+ target:
13
+ description: 'Target repository (testpypi or pypi)'
14
+ required: true
15
+ default: 'testpypi'
16
+ type: choice
17
+ options:
18
+ - testpypi
19
+ - pypi
20
+
21
+ permissions:
22
+ contents: read
23
+
24
+ jobs:
25
+ make_wheel:
26
+ runs-on: ubuntu-latest
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - uses: actions/setup-python@v5
31
+ with:
32
+ python-version: "3.12"
33
+
34
+ - name: Get version (using TAG)
35
+ if: (github.event_name == 'push' || github.event_name == 'release' )
36
+ id: get_version
37
+ run: |
38
+ VERSION=${GITHUB_REF#refs/tags/v}
39
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
40
+ echo "VERSION_TAG=$VERSION" >> $GITHUB_ENV
41
+
42
+ - name: Get version (manual)
43
+ if: (github.event_name == 'workflow_dispatch' && github.event.inputs.target == 'testpypi')
44
+ id: get_version_manual
45
+ run: |
46
+ VERSION="0.0.1"
47
+ echo "VERSION=$VERSION" >> $GITHUB_ENV
48
+ echo "VERSION_TAG=$VERSION" >> $GITHUB_ENV
49
+ echo "BUILD_NUMBER=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
50
+ echo "FULL_VERSION=$VERSION.$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
51
+
52
+ - name: Update version in __init__.py
53
+ run: |
54
+ echo "Version: $VERSION_TAG"
55
+ sed -i "s/__version__ = \"0.1.1\"/__version__ = \"$VERSION_TAG\"/" orsa/__init__.py
56
+
57
+ - name: Build distributions
58
+ run: |
59
+ python -m pip install build twine
60
+ python -m build
61
+
62
+ - name: Upload distributions
63
+ uses: actions/upload-artifact@v4
64
+ with:
65
+ name: make_wheel
66
+ path: dist/
67
+
68
+ pypi-publish:
69
+ runs-on: ubuntu-latest
70
+ needs:
71
+ - make_wheel
72
+ permissions:
73
+ id-token: write
74
+
75
+ environment:
76
+ name: pypi
77
+
78
+ steps:
79
+ - name: Retrieve WHEEL distributions
80
+ uses: actions/download-artifact@v4
81
+ with:
82
+ name: make_wheel
83
+ path: dist/
84
+
85
+ - name: Publish distributions to PyPI
86
+ if: (github.event_name == 'push' || github.event_name == 'release')
87
+ uses: pypa/gh-action-pypi-publish@release/v1
88
+ with:
89
+ packages-dir: dist/
90
+ repository-url: https://upload.pypi.org/legacy/
91
+ user: __token__
92
+ password: ${{ secrets.PYPI_API_TOKEN }}
93
+
94
+ - name: Publish distributions to TestPyPI
95
+ if: (github.event.inputs.target == 'testpypi')
96
+ uses: pypa/gh-action-pypi-publish@release/v1
97
+ with:
98
+ packages-dir: dist/
99
+ repository-url: https://test.pypi.org/legacy/
100
+ user: __token__
101
+ password: ${{ secrets.TEST_PYPI_API_TOKEN }}
orsa-0.1.1/.gitignore ADDED
@@ -0,0 +1,364 @@
1
+ ## Ignore Visual Studio temporary files, build results, and
2
+ ## files generated by popular Visual Studio add-ons.
3
+ ##
4
+ ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5
+
6
+ # User-specific files
7
+ *.rsuser
8
+ *.suo
9
+ *.user
10
+ *.userosscache
11
+ *.sln.docstates
12
+
13
+ # User-specific files (MonoDevelop/Xamarin Studio)
14
+ *.userprefs
15
+
16
+ # Mono auto generated files
17
+ mono_crash.*
18
+
19
+ # Build results
20
+ [Dd]ist/
21
+ [Dd]ebug/
22
+ [Dd]ebugPublic/
23
+ [Rr]elease/
24
+ [Rr]eleases/
25
+ x64/
26
+ x86/
27
+ [Ww][Ii][Nn]32/
28
+ [Aa][Rr][Mm]/
29
+ [Aa][Rr][Mm]64/
30
+ bld/
31
+ [Bb]in/
32
+ [Oo]bj/
33
+ [Oo]ut/
34
+ [Ll]og/
35
+ [Ll]ogs/
36
+
37
+ # Visual Studio 2015/2017 cache/options directory
38
+ .vs/
39
+ # Uncomment if you have tasks that create the project's static files in wwwroot
40
+ #wwwroot/
41
+
42
+ # Visual Studio 2017 auto generated files
43
+ Generated\ Files/
44
+
45
+ # MSTest test Results
46
+ [Tt]est[Rr]esult*/
47
+ [Bb]uild[Ll]og.*
48
+ *.egg-info
49
+ # NUnit
50
+ *.VisualState.xml
51
+ TestResult.xml
52
+ nunit-*.xml
53
+
54
+ # Build Results of an ATL Project
55
+ [Dd]ebugPS/
56
+ [Rr]eleasePS/
57
+ dlldata.c
58
+
59
+ # Benchmark Results
60
+ BenchmarkDotNet.Artifacts/
61
+
62
+ # .NET Core
63
+ project.lock.json
64
+ project.fragment.lock.json
65
+ artifacts/
66
+
67
+ # ASP.NET Scaffolding
68
+ ScaffoldingReadMe.txt
69
+
70
+ # StyleCop
71
+ StyleCopReport.xml
72
+
73
+ # Files built by Visual Studio
74
+ *_i.c
75
+ *_p.c
76
+ *_h.h
77
+ *.ilk
78
+ *.meta
79
+ *.obj
80
+ *.iobj
81
+ *.pch
82
+ *.pdb
83
+ *.ipdb
84
+ *.pgc
85
+ *.pgd
86
+ *.rsp
87
+ *.sbr
88
+ *.tlb
89
+ *.tli
90
+ *.tlh
91
+ *.tmp
92
+ *.tmp_proj
93
+ *_wpftmp.csproj
94
+ *.log
95
+ *.vspscc
96
+ *.vssscc
97
+ .builds
98
+ *.pidb
99
+ *.svclog
100
+ *.scc
101
+
102
+ # Chutzpah Test files
103
+ _Chutzpah*
104
+
105
+ # Visual C++ cache files
106
+ ipch/
107
+ *.aps
108
+ *.ncb
109
+ *.opendb
110
+ *.opensdf
111
+ *.sdf
112
+ *.cachefile
113
+ *.VC.db
114
+ *.VC.VC.opendb
115
+
116
+ # Visual Studio profiler
117
+ *.psess
118
+ *.vsp
119
+ *.vspx
120
+ *.sap
121
+
122
+ # Visual Studio Trace Files
123
+ *.e2e
124
+
125
+ # TFS 2012 Local Workspace
126
+ $tf/
127
+
128
+ # Guidance Automation Toolkit
129
+ *.gpState
130
+
131
+ # ReSharper is a .NET coding add-in
132
+ _ReSharper*/
133
+ *.[Rr]e[Ss]harper
134
+ *.DotSettings.user
135
+
136
+ # TeamCity is a build add-in
137
+ _TeamCity*
138
+
139
+ # DotCover is a Code Coverage Tool
140
+ *.dotCover
141
+
142
+ # AxoCover is a Code Coverage Tool
143
+ .axoCover/*
144
+ !.axoCover/settings.json
145
+
146
+ # Coverlet is a free, cross platform Code Coverage Tool
147
+ coverage*.json
148
+ coverage*.xml
149
+ coverage*.info
150
+
151
+ # Visual Studio code coverage results
152
+ *.coverage
153
+ *.coveragexml
154
+
155
+ # NCrunch
156
+ _NCrunch_*
157
+ .*crunch*.local.xml
158
+ nCrunchTemp_*
159
+
160
+ # MightyMoose
161
+ *.mm.*
162
+ AutoTest.Net/
163
+
164
+ # Web workbench (sass)
165
+ .sass-cache/
166
+
167
+ # Installshield output folder
168
+ [Ee]xpress/
169
+
170
+ # DocProject is a documentation generator add-in
171
+ DocProject/buildhelp/
172
+ DocProject/Help/*.HxT
173
+ DocProject/Help/*.HxC
174
+ DocProject/Help/*.hhc
175
+ DocProject/Help/*.hhk
176
+ DocProject/Help/*.hhp
177
+ DocProject/Help/Html2
178
+ DocProject/Help/html
179
+
180
+ # Click-Once directory
181
+ publish/
182
+
183
+ # Publish Web Output
184
+ *.[Pp]ublish.xml
185
+ *.azurePubxml
186
+ # Note: Comment the next line if you want to checkin your web deploy settings,
187
+ # but database connection strings (with potential passwords) will be unencrypted
188
+ *.pubxml
189
+ *.publishproj
190
+
191
+ # Microsoft Azure Web App publish settings. Comment the next line if you want to
192
+ # checkin your Azure Web App publish settings, but sensitive information contained
193
+ # in these scripts will be unencrypted
194
+ PublishScripts/
195
+
196
+ # NuGet Packages
197
+ *.nupkg
198
+ # NuGet Symbol Packages
199
+ *.snupkg
200
+ # The packages folder can be ignored because of Package Restore
201
+ **/[Pp]ackages/*
202
+ # except build/, which is used as an MSBuild target.
203
+ !**/[Pp]ackages/build/
204
+ # Uncomment if necessary however generally it will be regenerated when needed
205
+ #!**/[Pp]ackages/repositories.config
206
+ # NuGet v3's project.json files produces more ignorable files
207
+ *.nuget.props
208
+ *.nuget.targets
209
+
210
+ # Microsoft Azure Build Output
211
+ csx/
212
+ *.build.csdef
213
+
214
+ # Microsoft Azure Emulator
215
+ ecf/
216
+ rcf/
217
+
218
+ # Windows Store app package directories and files
219
+ AppPackages/
220
+ BundleArtifacts/
221
+ Package.StoreAssociation.xml
222
+ _pkginfo.txt
223
+ *.appx
224
+ *.appxbundle
225
+ *.appxupload
226
+
227
+ # Visual Studio cache files
228
+ # files ending in .cache can be ignored
229
+ *.[Cc]ache
230
+ # but keep track of directories ending in .cache
231
+ !?*.[Cc]ache/
232
+
233
+ # Others
234
+ ClientBin/
235
+ ~$*
236
+ *~
237
+ *.dbmdl
238
+ *.dbproj.schemaview
239
+ *.jfm
240
+ *.pfx
241
+ *.publishsettings
242
+ orleans.codegen.cs
243
+
244
+ # Including strong name files can present a security risk
245
+ # (https://github.com/github/gitignore/pull/2483#issue-259490424)
246
+ #*.snk
247
+
248
+ # Since there are multiple workflows, uncomment next line to ignore bower_components
249
+ # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
250
+ #bower_components/
251
+
252
+ # RIA/Silverlight projects
253
+ Generated_Code/
254
+
255
+ # Backup & report files from converting an old project file
256
+ # to a newer Visual Studio version. Backup files are not needed,
257
+ # because we have git ;-)
258
+ _UpgradeReport_Files/
259
+ Backup*/
260
+ UpgradeLog*.XML
261
+ UpgradeLog*.htm
262
+ ServiceFabricBackup/
263
+ *.rptproj.bak
264
+
265
+ # SQL Server files
266
+ *.mdf
267
+ *.ldf
268
+ *.ndf
269
+
270
+ # Business Intelligence projects
271
+ *.rdl.data
272
+ *.bim.layout
273
+ *.bim_*.settings
274
+ *.rptproj.rsuser
275
+ *- [Bb]ackup.rdl
276
+ *- [Bb]ackup ([0-9]).rdl
277
+ *- [Bb]ackup ([0-9][0-9]).rdl
278
+
279
+ # Microsoft Fakes
280
+ FakesAssemblies/
281
+
282
+ # GhostDoc plugin setting file
283
+ *.GhostDoc.xml
284
+
285
+ # Node.js Tools for Visual Studio
286
+ .ntvs_analysis.dat
287
+ node_modules/
288
+
289
+ # Visual Studio 6 build log
290
+ *.plg
291
+
292
+ # Visual Studio 6 workspace options file
293
+ *.opt
294
+
295
+ # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
296
+ *.vbw
297
+
298
+ # Visual Studio LightSwitch build output
299
+ **/*.HTMLClient/GeneratedArtifacts
300
+ **/*.DesktopClient/GeneratedArtifacts
301
+ **/*.DesktopClient/ModelManifest.xml
302
+ **/*.Server/GeneratedArtifacts
303
+ **/*.Server/ModelManifest.xml
304
+ _Pvt_Extensions
305
+
306
+ # Paket dependency manager
307
+ .paket/paket.exe
308
+ paket-files/
309
+
310
+ # FAKE - F# Make
311
+ .fake/
312
+
313
+ # CodeRush personal settings
314
+ .cr/personal
315
+
316
+ # Python Tools for Visual Studio (PTVS)
317
+ __pycache__/
318
+ *.pyc
319
+
320
+ # Cake - Uncomment if you are using it
321
+ # tools/**
322
+ # !tools/packages.config
323
+
324
+ # Tabs Studio
325
+ *.tss
326
+
327
+ # Telerik's JustMock configuration file
328
+ *.jmconfig
329
+
330
+ # BizTalk build output
331
+ *.btp.cs
332
+ *.btm.cs
333
+ *.odx.cs
334
+ *.xsd.cs
335
+
336
+ # OpenCover UI analysis results
337
+ OpenCover/
338
+
339
+ # Azure Stream Analytics local run output
340
+ ASALocalRun/
341
+
342
+ # MSBuild Binary and Structured Log
343
+ *.binlog
344
+
345
+ # NVidia Nsight GPU debugger configuration file
346
+ *.nvuser
347
+
348
+ # MFractors (Xamarin productivity tool) working folder
349
+ .mfractor/
350
+
351
+ # Local History for Visual Studio
352
+ .localhistory/
353
+
354
+ # BeatPulse healthcheck temp database
355
+ healthchecksdb
356
+
357
+ # Backup folder for Package Reference Convert tool in Visual Studio 2017
358
+ MigrationBackup/
359
+
360
+ # Ionide (cross platform F# VS Code tools) working folder
361
+ .ionide/
362
+
363
+ # Fody - auto-generated XML schema
364
+ FodyWeavers.xsd
orsa-0.1.1/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
orsa-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,104 @@
1
+ Metadata-Version: 2.4
2
+ Name: orsa
3
+ Version: 0.1.1
4
+ Summary: Flexible and extensible implementation of the Saga patterns
5
+ Author-email: Andrei Yakubouski <yakubouski.a@yandex.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/yakubouski/orsa
8
+ Project-URL: Repository, https://github.com/yakubouski/orsa
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Topic :: Office/Business
14
+ Requires-Python: >=3.11
15
+ Description-Content-Type: text/markdown
16
+ License-File: LICENSE.txt
17
+ Requires-Dist: asyncio
18
+ Dynamic: license-file
19
+
20
+ # ORSA (<u>OR</u>chestrator <u>SA</u>ga)
21
+
22
+ This module provides a flexible and extensible framework for implementing Saga patterns in Python.
23
+ It enables coordination of complex business transactions spanning multiple services, ensuring eventual consistency through choreography and compensation mechanisms.
24
+
25
+ ### Key features include:
26
+
27
+ * **Simplified Saga Declaration** - Streamlined saga declaration using decorators and intuitive syntaxis, enabling rapid creation of complex distributed transactions
28
+
29
+ * **Saga Orchestration** - Full-featured saga orchestration with support for complex execution scenarios, including parallel and sequential operations
30
+
31
+ * **Extensible Saga Execution Manager** - Extendable saga execution manager with customizable execution strategies and error handling capabilities
32
+
33
+ * **Compensation Logic Management** - Automated compensation logic management with support for compensation chains and complex rollback scenarios
34
+
35
+ * **Asynchronous Execution** - Asynchronous saga execution support with handling of long-running operations and events
36
+
37
+ * **Readiness Probe Before Saga Execution** - Pre-execution system readiness checks with automatic dependency and resource discovery
38
+
39
+ ### Example
40
+
41
+ `saga_example.py`
42
+
43
+ ```Python
44
+ import httpx
45
+ from logging import getLogger
46
+ from orsa import orchestrator, Saga, Result
47
+
48
+ _logger = getLogger('EXAMPLES')
49
+
50
+ @orchestrator
51
+ async def currency_exchange(saga: Saga, amount: float, fromCurrency: str, toCurrency: str):
52
+ """
53
+ Sample Saga. Exchange from currencies
54
+ """
55
+ @saga.step(retry=3) # Number of retries for this step
56
+ async def get_exchange_rates() -> dict[str,tuple[float,float]]:
57
+ async with httpx.AsyncClient() as cli:
58
+ res = await cli.get('https://api.nbrb.by/exrates/rates?periodicity=0')
59
+ res.raise_for_status()
60
+ data = res.json()
61
+ _logger.info("Obtain exchange rates ... success (%d)",len(data))
62
+ return { cur['Cur_Abbreviation']: (cur['Cur_OfficialRate'],cur['Cur_Scale']) for cur in data }
63
+
64
+ @saga.step
65
+ def convert_to_base_currency(ExchRates: Result[dict[str,tuple[float,float]], get_exchange_rates]) -> float:
66
+ _rate, _scale = ExchRates[fromCurrency]
67
+ _baseAmount = amount * (_rate / _scale)
68
+
69
+ _logger.info("Convert %.3f (%s) to %.3f (BYN) ... rate (%.3f)",amount, fromCurrency, _baseAmount, (_rate / _scale))
70
+
71
+ return _baseAmount
72
+
73
+ @saga.step
74
+ def convert_to_dst_currency(
75
+ BaseAmount: Result[float,convert_to_base_currency],
76
+ ExchRates: Result[dict[str,tuple[float,float]], get_exchange_rates]) -> float:
77
+
78
+ _rate, _scale = ExchRates[toCurrency]
79
+ _dstAmount = BaseAmount / (_rate / _scale)
80
+
81
+ _logger.info("Convert %.3f (%s) to %.3f (%s)",amount, fromCurrency, _dstAmount, toCurrency)
82
+
83
+ return _dstAmount
84
+ ```
85
+
86
+ `main.py`
87
+ ```Python
88
+ import asyncio, logging
89
+ from saga_example import currency_exchange
90
+
91
+ logging.basicConfig(level=logging.INFO)
92
+
93
+ async def add_task():
94
+ await currency_exchange(45.12,'USD','CNY')
95
+
96
+ if __name__ == "__main__":
97
+ asyncio.run(add_task())
98
+ ```
99
+
100
+ [See other examples](https://github.com/yakubouski/orsa/)
101
+
102
+ ### License
103
+
104
+ [MIT License](LICENSE.txt)