Skip to content

Commit

Permalink
Merge pull request #6 from katajakasa/use-poetry
Browse files Browse the repository at this point in the history
Use poetry
  • Loading branch information
katajakasa authored Jul 10, 2022
2 parents ae47829 + 5946ce3 commit cc6a03e
Show file tree
Hide file tree
Showing 10 changed files with 1,304 additions and 174 deletions.
19 changes: 9 additions & 10 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package
name: CI

on:
push:
Expand All @@ -11,7 +11,6 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
Expand All @@ -24,15 +23,15 @@ jobs:
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install prerequisites
run: python -m pip install --upgrade pip poetry
- name: Create virtualenv
run: poetry env use ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Check with flake8
run: flake8
run: poetry install --no-root
- name: Check with Black
run: black --check aiohttp_spyne/
run: poetry run black --check aiohttp_spyne/
- name: Check with mypy
run: mypy -p aiohttp_spyne
run: poetry run mypy -p aiohttp_spyne
- name: Test with pytest
run: pytest
run: poetry run pytest
98 changes: 98 additions & 0 deletions README.md
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.
106 changes: 0 additions & 106 deletions README.rst

This file was deleted.

Loading

0 comments on commit cc6a03e

Please sign in to comment.