Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Add a default values for rpc with empty message

Đang mở
#613 1 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
grpc, python
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Issue không xác định tệp hoặc bài kiểm thử nào. Hãy bắt đầu bằng cách tìm các chữ ký phương thức RPC Python được sinh ra và cách xử lý hiện tại đối với google.protobuf.Empty hoặc các message không có trường; hoàn thành nghĩa là các RPC sử dụng message rỗng có thể được gọi mà không cần đối số, trong khi các lời gọi hiện có với message tường minh vẫn tiếp tục hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

enhancement
The Problem

Sometimes, it is needed to declare RPCs that take no parameter. However, it is not possible in gRPC. In such a situation, it is needed to either create an empty message type, or to use google.protobuf.Empty ( https://stackoverflow.com/questions/29687243/protobuf-rpc-service-method-without-parameters ).

However, this is not convenient for the final user: an empty message need to be created and passed to the method each time. It also makes it necessary to add potentially long imports.

The Ideal Solution

To make this easier, it would be better to add a default value for the parameter containing the request when it is possible. I see two possibilities:

  • Add the default value only for google.protobug.Empty
  • Add the default value for all the messages who have no field at all

I think the second solution would be better as it is common to define empty messages in such situations. I can make a PR if you agree, I already have a working version locally.

The Current Solution

Currently, it is necessary for the user to import by hand from betterproto.lib.std.google.protobuf import Empty or the custom message, which is not convenient.

The feature would turn:

from betterproto.lib.std.google.protobuf import Empty
answer = TestStub().call(Empty())

To something like:

answer = TestStub().call()
Ngôn ngữ chính
Python
Star
1.8k
Fork
235
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của danielgtaylor/python-betterproto

Tất cả issue của danielgtaylor/python-betterproto

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.