Skip to content

Commit

Permalink
Fixed processing of heartbeats and a session expiration and addeds su…
Browse files Browse the repository at this point in the history
…pport of aiohttp_cors (#448)

* - Fixed processing of heartbeats and a session expiration.
- Fixed ping-pong based heartbeats for web-socket connections.
- Added arguments ``heartbeat_delay`` and ``disconnect_delay`` into ``Session.__init__()``.
- Added argument ``disconnect_delay`` into ``SessionManager.__init__()``.
- **Breaking change:** Removed argument ``timeout`` from ``Session.__init__()`` and ``SessionManager.__init__()``.
- **Breaking change:** Argument ``heartbeat`` of ``SessionManager.__init__()`` renamed into ``heartbeat_delay``.
- **Breaking change:** ``Session.registry`` renamed into ``Session.app``.
- **Breaking change:** Dropped support of Python < 3.7

* Deleted method ``SessionManager.route_url()``.

* Added release date into CHANGES.rst

* Removed commented code from tests and fixed CHANGES.rst

* - Added argument ``cors_config`` into function ``add_endpoint()`` to support of CORS settings from ``aiohttp_cors``.
- Function ``add_endpoint()`` now returns all registered routes.
- Replaced returning instances of error HTTP responses on raising its as exceptions.
- Changed name of some routes.

* Fixed GitHub actions

* Fixed GitHub actions

* Fixed GitHub actions

* Fixed version of flake8 to support Python 3.7

* Fixed typing

* Reverted pytest-timeout

* Removed embedded CORS processing.

* Added arguments ``heartbeat_delay`` and ``disconnect_delay`` into function ``add_endpoint()``.

* - Heartbeat task moved from ``SessionManager`` into ``Session``.
- Methods ``_acquire`` and ``_release`` of ``Sessions`` renamed into ``acquire`` and ``release``.

* Added processing of ``ConnectionError`` in ``StreamingTransport``.

* Fixed name of transports.

* - Changed arguments of handler function. Now handler function must be defined
  like ``async def handler(manager, session, msg):``
- Constants:

  - FRAME_OPEN
  - FRAME_CLOSE
  - FRAME_MESSAGE
  - FRAME_MESSAGE_BLOB
  - FRAME_HEARTBEAT

  replaced by ``Frame`` enums with corresponding values.
- Constants:

  - MSG_OPEN
  - MSG_MESSAGE
  - MSG_CLOSE
  - MSG_CLOSED

  replaced by ``MsgType`` enums with corresponding values.
- Constants:

  - STATE_NEW
  - STATE_OPEN
  - STATE_CLOSING
  - STATE_CLOSED

  replaced by ``SessionState`` enums with corresponding values.

* Fixed error processing in StreamingTransport

* Changed supported versions of Python.

* Added "sockjs_transport_name" into request object.

* - Updated dependencies versions.
- Fixed code style.

* Fixed dependencies.

* Fixed versions of GitHub actions.
  • Loading branch information
Cykooz authored Jun 13, 2024
1 parent 7404214 commit ab16e84
Show file tree
Hide file tree
Showing 50 changed files with 1,797 additions and 1,902 deletions.
7 changes: 0 additions & 7 deletions .coveragerc

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/check_and_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Check and Test

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch: {}


jobs:
run_tests:
strategy:
matrix:
python-version: [ "3.10", "3.11", "3.12" ]

name: Test on Python ${{ matrix.python-version }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
architecture: x64

- name: Install dependencies
run: |
python -m pip install --upgrade setuptools
python -m pip install -r requirements.txt
python -m pip install -e .[test]
- name: Run checks and tests
run: |
make flake
pytest ./tests
6 changes: 3 additions & 3 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
python -m pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ eggs
sources
dist
develop-eggs
build
*.egg-info
*.pyc
*.pyo
Expand Down
31 changes: 0 additions & 31 deletions .travis.yml

This file was deleted.

60 changes: 60 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,66 @@
CHANGES
=======

0.13.0 (not-released)
---------------------

- Added argument ``cors_config`` into function ``add_endpoint()``
to support of CORS settings from ``aiohttp_cors``.
- Added arguments ``heartbeat_delay`` and ``disconnect_delay``
into function ``add_endpoint()``.
- Function ``add_endpoint()`` now returns all registered routes.
- Replaced returning instances of error HTTP responses
on raising its as exceptions.
- Changed name of some routes.
- Heartbeat task moved from ``SessionManager`` into ``Session``.
- Methods ``_acquire`` and ``_release`` of ``Sessions`` renamed into
``acquire`` and ``release``.
- Added processing of ``ConnectionError`` in ``StreamingTransport``.
- Changed arguments of handler function. Now handler function must be defined
like ``async def handler(manager, session, msg):``
- Constants:

- FRAME_OPEN
- FRAME_CLOSE
- FRAME_MESSAGE
- FRAME_MESSAGE_BLOB
- FRAME_HEARTBEAT

replaced by ``Frame`` enums with corresponding values.
- Constants:

- MSG_OPEN
- MSG_MESSAGE
- MSG_CLOSE
- MSG_CLOSED

replaced by ``MsgType`` enums with corresponding values.
- Constants:

- STATE_NEW
- STATE_OPEN
- STATE_CLOSING
- STATE_CLOSED

replaced by ``SessionState`` enums with corresponding values.


0.12.0 (2022-02-08)
-------------------

- **Breaking change:** Removed argument ``timeout`` from ``Session.__init__()``
and ``SessionManager.__init__()``.
- **Breaking change:** Argument ``heartbeat`` of ``SessionManager.__init__()``
renamed into ``heartbeat_delay``.
- **Breaking change:** ``Session.registry`` renamed into ``Session.app``.
- **Breaking change:** Deleted method ``SessionManager.route_url()``.
- **Breaking change:** Dropped support of Python < 3.7
- Fixed processing of heartbeats and a session expiration.
- Fixed ping-pong based heartbeats for web-socket connections.
- Added arguments ``heartbeat_delay`` and ``disconnect_delay`` into
``Session.__init__()``.
- Added argument ``disconnect_delay`` into ``SessionManager.__init__()``.

0.11.0 (2020-10-22)
-------------------

Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ include README.rst
include Makefile
include sockjs-testsrv.py
graft sockjs
graft docs
graft examples
graft tests
global-exclude *.pyc
21 changes: 2 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,17 @@ FLAGS=


flake:
# python setup.py check -rms
flake8 sockjs tests examples
if python -c "import sys; sys.exit(sys.version_info<(3,6))"; then \
black --check sockjs tests setup.py; \
fi

fmt:
black sockjs tests setup.py


develop:
python setup.py develop
pip install -e .[test]

test: flake develop
pytest $(FLAGS) ./tests/

vtest: flake develop
pytest -s -v $(FLAGS) ./tests/

cov cover coverage: flake develop
@py.test --cov=sockjs --cov-report=term --cov-report=html tests
@echo "open file://`pwd`/coverage/index.html"

clean:
rm -rf `find . -name __pycache__`
rm -f `find . -type f -name '*.py[co]' `
Expand All @@ -40,11 +28,6 @@ clean:
rm -rf coverage
rm -rf build
rm -rf cover
make -C docs clean
python setup.py clean

doc:
make -C docs html
@echo "open file://`pwd`/docs/_build/html/index.html"

.PHONY: all build venv flake test vtest testloop cov clean doc
.PHONY: all flake test vtest clean
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Supported transports
Requirements
------------

- Python 3.5.3
- Python 3.10.0

- gunicorn 19.2.0

Expand Down
67 changes: 0 additions & 67 deletions docs/Makefile

This file was deleted.

23 changes: 0 additions & 23 deletions docs/api.rst

This file was deleted.

Loading

0 comments on commit ab16e84

Please sign in to comment.