Skip to main content

a3grpc

English | 简体中文

a3grpc is a simple wrapper around grpc to make it easier to use.

1. Introduction

Server

  • Similar to Django, one API corresponds to one View. Inherit the base class View and return error information to the client by throwing exceptions.
  • Use Servicer to contain the relevant Views.
  • Write servicer_mappings. Similar to Django urls, multiple Servicers can be configured.
  • Prepare the following configuration conf and call run_grpc_server or run_grpc_server_with_multiprocessing to start the service.
conf = {
    # Optional. Number of processes. It will be used when using run_grpc_server_with_multiprocessing. If not specified, it will be the cpu_count.
    "process_count": 3,
    # Required.
    "host": "127.0.0.1",
    # Required.
    "port": 50051,
    # Required. Number of workers.
    "max_workers": 10,
    # Required. Number of concurrent connections.
    "maximum_concurrent_rpcs": 100,
    # Required. Mapping between add_func and Servicer.
    "servicer_mappings": "app.mappings.servicer_mappings",
    # Optional. SSL certificate.
    "server_key": "/data/ssl/server-key.pem",
    "server_cert": "/data/ssl/server.pem",
    "ca_cert": "/data/ssl/ca.pem",
    # Optional. Graceful shutdown seconds.
    "graceful_shutdown_seconds": 10,
    # Optional. Underlying configuration, details:https://grpc.github.io/grpc/core/group__grpc__arg__keys.html
    "options": (
        ("grpc.keepalive_time_ms", 10000),
        ("grpc.keepalive_timeout_ms", 5000),
        ("grpc.keepalive_permit_without_calls", True),
        ("grpc.http2.max_pings_without_data", 0),
        ("grpc.http2.min_ping_interval_without_data_ms", 5000),
        ("grpc.max_receive_message_length", 20 * 1024 * 1024),
        ("grpc.max_send_message_length", 20 * 1024 * 1024),
    ),
    # Optional. Similar to Django middlewares.
    "interceptors": [
        "app.interceptors.Interceptor",
    ],
    # Optional. Customize the status code.
    "patch_status_code": {
        "client_site_error_code": 499,
        "server_site_error_code": 599,
    }
}

Client

  • Inherit BaseClient and implement target APIs
  • If the server return an exception, it will automatically throw the exception instance.

2. Usage

Install

pip install a3grpc

Examples

Metadata

Release files for a3grpc 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for a3grpc 0.3.0
File Size Uploaded
a3grpc-0.3.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for a3grpc 0.3.0
File Interpreter ABI Platform
a3grpc-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 20.1 kB

Release files / a3grpc-0.3.0.tar.gz

Download URL a3grpc-0.3.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
834369efb02646db773e2b3b746594bbaaafa8e171e5c47385e830bacce8e663
BLAKE2b-256 checksum
How to use checksums
9948c46b01d2e32819ccc60f6924216668e60f9c6d90b89f0d133a51877bb091
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / a3grpc-0.3.0-py3-none-any.whl

Download URL a3grpc-0.3.0-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9951a5418d2b5ebd03a2216fde77ebf81eda090cbe009894d2189eabd5c5f37
BLAKE2b-256 checksum
How to use checksums
467b295712644b6d1b03817b71f89f97d398004f6fd7f6d8c549159cf75cde93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page