Skip to content

Commit e790c18

Browse files
committed
Merge branch 'master' into channels
# Conflicts: # CHANGELOG.rst # README.md # requirements.txt
2 parents 40b2aaa + d181a3a commit e790c18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+961
-92
lines changed

.github/workflows/python-package.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
19+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2020
steps:
2121
- uses: actions/checkout@v2
2222
- name: Set up Python ${{ matrix.python-version }}
@@ -37,10 +37,11 @@ jobs:
3737
run: |
3838
pytest -n 1 --reruns 5 --cov-report=html --cov --ignore=examples tests
3939
- name: Archive code coverage html report
40-
uses: actions/upload-artifact@v2
40+
uses: actions/upload-artifact@v4
4141
with:
4242
name: code-coverage-report
4343
path: coverage_report_html
44+
overwrite: true
4445
- name: Publish coveralls
4546
continue-on-error: true
4647
env:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,4 @@ ENV/
9191
# PyCharm
9292
*.iml
9393
.idea/
94+
python311/

.junie/guidelines.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
2+
# RSocket-py Project Analysis
3+
4+
## Overview
5+
RSocket-py is a Python implementation of the [RSocket](http://rsocket.io) protocol, which is a binary protocol for use on byte stream transports such as TCP, WebSockets, and Aeron. The project provides a comprehensive implementation of the RSocket protocol with support for various transports, extensions, and integrations.
6+
7+
## Key Components
8+
9+
### Core Architecture
10+
- **RSocketBase**: The foundational class implementing the RSocket protocol, handling frame processing, stream management, and connection lifecycle.
11+
- **Transport Layer**: Supports multiple transports including TCP, WebSocket (via aiohttp, fastapi, quart, websockets), and QUIC.
12+
- **Request Handlers**: Implements the different interaction models (request-response, fire-and-forget, request-stream, request-channel).
13+
- **ReactiveX Integration**: Provides integration with ReactiveX (both v3 and v4) for reactive programming support.
14+
15+
### Interaction Models
16+
- **Request-Response**: Simple request with a single response.
17+
- **Fire-and-Forget**: One-way message with no response.
18+
- **Request-Stream**: Request that receives a stream of responses.
19+
- **Request-Channel**: Bi-directional stream of messages.
20+
- **Metadata Push**: Metadata-only message with no response.
21+
22+
### Extensions
23+
- **Composite Metadata**: Support for multiple metadata entries in a single payload.
24+
- **Routing**: Request routing capabilities similar to HTTP routing.
25+
- **Authentication**: Built-in authentication mechanisms.
26+
- **Fragmentation**: Support for breaking large messages into fragments.
27+
28+
### Reactive Streams
29+
- **Backpressure Support**: Implements the Reactive Streams specification for handling backpressure.
30+
- **Publisher/Subscriber Pattern**: Uses the publisher/subscriber pattern for stream handling.
31+
32+
## Project Structure
33+
34+
### Main Package (`rsocket/`)
35+
- **Core Protocol Implementation**: Base classes, frame handling, error codes.
36+
- **Handlers**: Implementation of different interaction models.
37+
- **Extensions**: Protocol extensions like routing, authentication.
38+
- **Transports**: Different transport implementations (TCP, WebSocket, QUIC).
39+
- **ReactiveX Integration**: Adapters for ReactiveX observables.
40+
41+
### Examples (`examples/`)
42+
- **Basic Examples**: Simple client-server interactions.
43+
- **Tutorial**: Step-by-step guide to using the library.
44+
- **Advanced Use Cases**: Streaming, routing, reconnection, etc.
45+
- **Bug Reproductions**: Examples demonstrating specific issues.
46+
47+
### Tests (`tests/`)
48+
- **Unit Tests**: Tests for individual components.
49+
- **Integration Tests**: Tests for component interactions.
50+
- **ReactiveX Tests**: Tests for ReactiveX integration.
51+
52+
## Streaming File Example Analysis
53+
54+
The streaming file example demonstrates how to stream a file from server to client using RSocket's request-stream interaction model:
55+
56+
### Server Side
57+
1. **File Reading**: Uses `aiofiles` to asynchronously read a file in chunks.
58+
2. **Stream Handler**: Implements a request-stream handler that reads file chunks and sends them to the client.
59+
3. **Backpressure Handling**: Uses ReactiveX's backpressure mechanisms to control the flow of data.
60+
4. **Routing**: Uses RSocket's routing capabilities to expose the stream endpoint.
61+
62+
### Client Side
63+
1. **Stream Request**: Initiates a request-stream interaction with the server.
64+
2. **Data Processing**: Processes the incoming stream of file chunks.
65+
3. **ReactiveX Integration**: Uses ReactiveX operators to transform and collect the stream data.
66+
67+
## Key Features and Capabilities
68+
69+
- **Async/Await Support**: Built on Python's asyncio for asynchronous programming.
70+
- **Backpressure Control**: Implements proper backpressure handling for stream processing.
71+
- **Extensibility**: Modular design allows for easy extension and customization.
72+
- **Multiple Transport Support**: Works with various transport protocols.
73+
- **Reactive Programming**: Integration with ReactiveX for reactive programming patterns.
74+
- **Routing**: Request routing similar to HTTP frameworks.
75+
- **Fragmentation**: Support for large messages through fragmentation.
76+
- **Command Line Interface**: Includes CLI tools for testing and debugging.
77+
78+
## Integration Options
79+
80+
The project supports integration with various Python libraries and frameworks:
81+
- **ReactiveX**: For reactive programming.
82+
- **aiohttp/fastapi/quart**: For WebSocket transport.
83+
- **CloudEvents**: For event-driven architectures.
84+
- **GraphQL**: For GraphQL API implementation.
85+
86+
## Conclusion
87+
88+
RSocket-py provides a comprehensive implementation of the RSocket protocol in Python, with support for all interaction models, various transports, and extensions. It's designed for building reactive, resilient, and efficient communication between services, particularly in microservice architectures. The project's modular design and extensive examples make it accessible for developers looking to implement RSocket-based communication in their Python applications.

.readthedocs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ build:
88
python:
99
install:
1010
- requirements: docs/requirements.txt
11+
- requirements: requirements.txt
1112
- method: pip
1213
path: .
13-
extra_requirements:
14-
- docs
14+
1515

1616
sphinx:
1717
configuration: docs/conf.py

CHANGELOG.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
Changelog
22
---------
33

4+
v0.4.18
5+
=======
6+
- Fixed Stalette/FastAPI implementation and added example using FastAPI server
7+
8+
v0.4.17
9+
=======
10+
- python 3.13 support
11+
- Documentation and example code update
12+
413
v0.4.16
514
=======
6-
- Channels (django) (https://github.com/django/channels) server support
15+
- Fix using router request-response with reactivex response
16+
- Fix examples of consuming the payload of a request-channel
17+
- Fix the reactivex example of the tutorial application
718

819
v0.4.15
920
=======

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ You may also install using some **extras**:
1717
| rx | ReactiveX ([v3](https://pypi.org/project/Rx/)) integration | [Tutorial](https://rsocket.io/guides/rsocket-py/tutorial/reactivex) |
1818
| reactivex | [ReactiveX](https://reactivex.io/) ([v4](https://pypi.org/project/reactivex/)) integration | [Tutorial](https://rsocket.io/guides/rsocket-py/tutorial/reactivex) |
1919
| aiohttp | [aiohttp](https://docs.aiohttp.org/en/stable/) Websocket transport (server/client) | [Tutorial](https://rsocket.io/guides/rsocket-py/tutorial/websocket) |
20+
| fastapi | [fastapi](https://github.com/fastapi/fastapi) Websocket transport (server/client) | |
2021
| channels | Websocket transport (server only) using channels (django) | |
2122
| quart | [Quart](https://pgjones.gitlab.io/quart/) Websocket transport (server only) | |
2223
| quic | [QUIC](https://github.com/aiortc/aioquic) transport | |
@@ -48,6 +49,7 @@ python3 setup.py install
4849
# Documentation
4950

5051
[Documentation](https://rsocket.io/guides/rsocket-py) is available on the official rsocket.io site.
52+
[API](https://rsocket.readthedocs.io/en/latest/index.html) documentation is at readthedocs.io.
5153

5254
# Examples
5355

@@ -74,6 +76,7 @@ the [Spring RSocket demo](https://github.com/benwilcock/spring-rsocket-demo).
7476
| | ServerWithFragmentation | client_with_routing.py | |
7577
| server_quart_websocket.py | | client_websocket.py | |
7678
| server_aiohttp_websocket.py | | client_websocket.py | |
79+
| server_fastapi_websocket.py | | client_websocket.py | |
7780
| server_graphql.py | ServerWithGraphQL | client_graphql.py | |
7881

7982
# Build Status

docs/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,4 @@ Transports
6565

6666
.. automodule:: rsocket.transports.transport
6767
:members:
68+

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525

2626
# The full version, including alpha/beta/rc tags
27-
release = '0.4.15'
27+
release = '0.4.18'
2828

2929
# -- General configuration ---------------------------------------------------
3030

@@ -35,7 +35,7 @@
3535
'sphinx.ext.autodoc',
3636
'sphinx.ext.autosummary',
3737
"sphinx.ext.napoleon",
38-
"sphinx.ext.viewcode"
38+
"sphinx.ext.viewcode",
3939
]
4040

4141
# Add any paths that contain templates here, relative to this directory.

docs/extensions.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ quart
2525
.. automodule:: rsocket.transports.quart_websocket
2626
:members:
2727

28+
websockets
29+
++++++++++
30+
31+
.. automodule:: rsocket.transports.websockets_transport
32+
:members:
33+
34+
asyncwebsockets
35+
+++++++++++++++
36+
37+
.. automodule:: rsocket.transports.asyncwebsockets_transport
38+
:members:
39+
2840
quic
2941
~~~~
3042

@@ -69,3 +81,32 @@ Strategies
6981
.. automodule:: rsocket.load_balancer.random_client
7082
:members:
7183
:inherited-members:
84+
85+
86+
ReactiveX
87+
---------
88+
89+
ReactiveX 4
90+
~~~~~~~~~~~
91+
92+
.. automodule:: rsocket.reactivex.reactivex_handler
93+
:members:
94+
:inherited-members:
95+
96+
97+
.. automodule:: rsocket.reactivex.reactivex_handler_adapter
98+
:members:
99+
:inherited-members:
100+
101+
102+
ReactiveX 3
103+
~~~~~~~~~~~
104+
105+
.. automodule:: rsocket.rx_support.rx_handler
106+
:members:
107+
:inherited-members:
108+
109+
110+
.. automodule:: rsocket.rx_support.rx_handler_adapter
111+
:members:
112+
:inherited-members:
File renamed without changes.

0 commit comments

Comments
 (0)