A small package for counting gRPC connections
Project description
gRPC Connection Forwarder
grpc_connection_forwarder is a Python package that helps you forward incoming TCP connections to a gRPC server. It is particularly useful when you need to track the number of active connections.
Features
- Forward incoming TCP connections to a gRPC server
- Connection counter with callback support
- Thread-safe implementation
- Easy integration with existing gRPC servers
Installation
You can install grpc_connection_forwarder using pip:
pip install grpc_connection_forwarder
Usage
Here's a simple example of how to use grpc_connection_forwarder with a gRPC server:
import grpc
from grpc_connection_forwarder import GrpcConnnectionForwarder
from your_grpc_package import YourGRPCServer
# Initialize your gRPC server
grpc_server = grpc.server(thread_pool=ThreadPoolExecutor())
your_grpc_service = YourGRPCServer()
# ... (add your services to the gRPC server)
# Define a callback function to handle connection count changes (optional)
def connection_count_callback(count):
print(f"Connected users: {count}")
# Initialize the gRPC Connection Forwarder
forwarder = GrpcConnnectionForwarder(grpc_server, callback=connection_count_callback)
# Start the forwarder
forwarder.serve(host='localhost', port=50051)
Contributing
We welcome contributions to grpc_connection_forwarder. If you find a bug or want to propose a new feature, please open a GitHub issue or submit a pull request.
License
This project is licensed under the MIT License. See LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grpc_connection_forwarder-0.1.5.tar.gz.
File metadata
- Download URL: grpc_connection_forwarder-0.1.5.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f6a0ad3d9061c708bf8dc8b12dd33ec5dc8fb1b049a5fc068307a65d4273529
|
|
| MD5 |
5f4140057d48c5306767d848e74332cf
|
|
| BLAKE2b-256 |
4c7a83b3df3d0f0b8aac28e210e57ae001be7d192c1c3a3d2f7009d964ccf091
|
File details
Details for the file grpc_connection_forwarder-0.1.5-py3-none-any.whl.
File metadata
- Download URL: grpc_connection_forwarder-0.1.5-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c49458e1bfb70b4ebbfbbc1db864d0a55932857eb3f9a810e50329f53b85a7f7
|
|
| MD5 |
ee8791f2cd39c2eff7b28c11751926e4
|
|
| BLAKE2b-256 |
4632193f15c47c2cc9aaf52ccbc2159053bc882573dfb238695a3464616ac4be
|