Skip to content

feat: Add support for simultaneous TCP and UDS binding#805

Open
IngmarStein wants to merge 1 commit intoemmett-framework:masterfrom
IngmarStein:feat/dual-socket-support
Open

feat: Add support for simultaneous TCP and UDS binding#805
IngmarStein wants to merge 1 commit intoemmett-framework:masterfrom
IngmarStein:feat/dual-socket-support

Conversation

@IngmarStein
Copy link
Copy Markdown
Contributor

This commit enables Granian to serve on both TCP sockets and Unix Domain Sockets concurrently.

Changes:

  • Updated Rust worker implementations (ASGI, RSGI, WSGI) to handle optional dual listeners.
  • Enhanced WorkerConfig to store both TCP and UDS socket holders.
  • Introduced new serve_*_dual macros and functions in Rust to manage concurrent listeners using tokio::join!.
  • Modified Python cli.py to allow both --host and --uds arguments to be specified.
  • Updated AbstractServer and server implementations (MP, MT) to initialize and pass both sockets to workers.
  • Added a new test case tests/test_dual_socket.py to verify simultaneous connectivity.
  • Updated granian/_granian.pyi type stubs to reflect the changes in worker constructors.

This commit enables Granian to serve on both TCP sockets and Unix Domain Sockets concurrently.

Changes:
- Updated Rust worker implementations (ASGI, RSGI, WSGI) to handle optional dual listeners.
- Enhanced `WorkerConfig` to store both TCP and UDS socket holders.
- Introduced new `serve_*_dual` macros and functions in Rust to manage concurrent listeners using `tokio::join!`.
- Modified Python `cli.py` to allow both `--host` and `--uds` arguments to be specified.
- Updated `AbstractServer` and server implementations (MP, MT) to initialize and pass both sockets to workers.
- Added a new test case `tests/test_dual_socket.py` to verify simultaneous connectivity.
- Updated `granian/_granian.pyi` type stubs to reflect the changes in worker constructors.
@IngmarStein IngmarStein marked this pull request as ready for review February 11, 2026 08:46
@gi0baro
Copy link
Copy Markdown
Member

gi0baro commented Feb 17, 2026

@IngmarStein can you expand on the use-case for this? While I get what this is about, I don't really get the why we would want this.

@IngmarStein
Copy link
Copy Markdown
Contributor Author

@gi0baro sorry about this, I should have linked to #97 (comment) as the motivation for the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants