-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from katajakasa/use-poetry
Use poetry
- Loading branch information
Showing
10 changed files
with
1,304 additions
and
174 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
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,98 @@ | ||
![CI](https://github.com/katajakasa/aiohttp-spyne/actions/workflows/python-package.yml/badge.svg) | ||
|
||
|
||
# About | ||
|
||
Aiohttp transport for Spyne RPC library. | ||
|
||
Requirements: | ||
|
||
* Python >= 3.7 | ||
* Aiohttp >= 3.7.0 | ||
* Spyne >= 2.14.0 | ||
|
||
Spyne alpha versions should also work. | ||
|
||
## Installation | ||
|
||
Just run `pip install aiohttp-spyne` :) | ||
|
||
## Examples | ||
|
||
* Test server: `python -m examples.hello_world` | ||
* Threaded test server: `python -m examples.hello_world_threads` | ||
* Test client: `python -m examples.test_client` | ||
|
||
## Usage | ||
|
||
First, initialize your spyne application as normal. Here's an example | ||
for a simple SOAP service (See spyne examples and documentation for | ||
a more complete service setup). | ||
|
||
``` | ||
spyne_app = spyne.Application( | ||
[HelloWorldService], | ||
tns='aiohttp_spyne.examples.hello', | ||
in_protocol=Soap11(validator='lxml'), | ||
out_protocol=Soap11()) | ||
``` | ||
|
||
Next, wrap your Spyne application with AIOSpyne. Note that you can run | ||
your application entrypoints in a thread by setting the "threads" parameter. | ||
If you want to keep your entrypoints running in the same thread as the | ||
main application, just leave this None. If you DO run your entrypoints | ||
in threads, be aware that some signals sent by spyne will also be run | ||
in threads, and be extra careful of using your main loop! | ||
|
||
``` | ||
handler = AIOSpyne(spyne_app, threads=25) | ||
``` | ||
|
||
Lastly, make an aiohttp application as usual, and just bind GET and POST | ||
entrypoints from AIOSpyne to wherever. Note that both paths need to be | ||
the same. | ||
|
||
With GET, if the request address ends ?wsdl or .wsdl, a WSDL schema is | ||
returned in a response. Otherwise, requests are redirected to spynes | ||
RPC handler. | ||
|
||
``` | ||
app = web.Application() | ||
app.router.add_get('/{tail:.*}', handler.get) | ||
app.router.add_post('/{tail:.*}', handler.post) | ||
web.run_app(app, port=8080) | ||
``` | ||
|
||
## Chunked encoding | ||
|
||
If you offer large result sets in your soap entrypoints, and yield | ||
the results properly, you may want to enable chunked encoding. This | ||
way the aiohttp server can stream your results and reduce memory | ||
usage. | ||
|
||
``` | ||
handler = AIOSpyne(spyne_app, chunked=True) | ||
``` | ||
|
||
## WSDL caching | ||
|
||
By default, aiohttp-spyne will cache WSDL documents generated by spyne. | ||
This makes it cheap to offer the WSDL documents to any clients. Sometimes | ||
you may need to disable this caching however (e.g. when you have requests | ||
coming from multiple source urls, and want to automatically generate | ||
the port address for each one). This can be done by settings the cache_wsdl | ||
option as False. | ||
|
||
``` | ||
handler = AIOSpyne(spyne_app, cache_wsdl=False) | ||
``` | ||
|
||
## Testing and formatting | ||
|
||
1. `pytest` | ||
2. `mypy -p aiohttp_spyne` | ||
4. `black aiohttp_spyne/` | ||
|
||
## License | ||
|
||
LGPL-2.1 -- Please see LICENSE for details. |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.