Skip to main content

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

grpc_connection_forwarder-0.1.5.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file grpc_connection_forwarder-0.1.5.tar.gz.

File metadata

File hashes

Hashes for grpc_connection_forwarder-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9f6a0ad3d9061c708bf8dc8b12dd33ec5dc8fb1b049a5fc068307a65d4273529
MD5 5f4140057d48c5306767d848e74332cf
BLAKE2b-256 4c7a83b3df3d0f0b8aac28e210e57ae001be7d192c1c3a3d2f7009d964ccf091

See more details on using hashes here.

File details

Details for the file grpc_connection_forwarder-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for grpc_connection_forwarder-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 c49458e1bfb70b4ebbfbbc1db864d0a55932857eb3f9a810e50329f53b85a7f7
MD5 ee8791f2cd39c2eff7b28c11751926e4
BLAKE2b-256 4632193f15c47c2cc9aaf52ccbc2159053bc882573dfb238695a3464616ac4be

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page