This is an automated email from the ASF dual-hosted git repository.

chaokunyang pushed a commit to branch update_1.2.0_grpc_python_guide
in repository https://gitbox.apache.org/repos/asf/fory-site.git

commit f5b6a249f82a1d503dc750cba722baee20580cca
Author: 慕白 <[email protected]>
AuthorDate: Tue Jun 16 23:24:44 2026 +0800

    Clarify Python gRPC channel configuration
---
 docs/guide/python/grpc-support.md                            | 11 +++++++----
 .../current/guide/python/grpc-support.md                     | 12 +++++++-----
 .../version-1.2.0/guide/python/grpc-support.md               | 12 +++++++-----
 versioned_docs/version-1.2.0/guide/python/grpc-support.md    | 11 +++++++----
 4 files changed, 28 insertions(+), 18 deletions(-)

diff --git a/docs/guide/python/grpc-support.md 
b/docs/guide/python/grpc-support.md
index 946602be30..65db689e63 100644
--- a/docs/guide/python/grpc-support.md
+++ b/docs/guide/python/grpc-support.md
@@ -29,8 +29,9 @@ encoding. Use standard protobuf gRPC code generation when 
clients or tools must
 consume protobuf message bytes directly.
 
 Generated Python companions currently target the synchronous `grpcio` API. Use
-regular `def` servicer methods, `grpc.server(...)`, 
`grpc.insecure_channel(...)`,
-and Python iterators or generators for streaming RPCs. The compiler does not
+regular `def` servicer methods, `grpc.server(...)`, standard `grpc.Channel`
+instances, and Python iterators or generators for streaming RPCs. The generated
+stub accepts any channel configured by your application. The compiler does not
 generate `grpc.aio` stubs or service bases, so do not implement generated
 servicer methods as `async def` unless you add a custom adapter outside the
 generated companion.
@@ -129,7 +130,8 @@ import demo_greeter_grpc
 
 
 def main():
-    with grpc.insecure_channel("localhost:50051") as channel:
+    credentials = grpc.ssl_channel_credentials()
+    with grpc.secure_channel("api.example.com:443", credentials) as channel:
         stub = demo_greeter_grpc.GreeterStub(channel)
         reply = stub.say_hello(demo_greeter.HelloRequest(name="Fory"))
         print(reply.reply)
@@ -188,7 +190,8 @@ class Greeter(demo_greeter_grpc.GreeterServicer):
 Generated clients use the standard `grpcio` streaming call shapes:
 
 ```python
-with grpc.insecure_channel("localhost:50051") as channel:
+credentials = grpc.ssl_channel_credentials()
+with grpc.secure_channel("api.example.com:443", credentials) as channel:
     stub = demo_greeter_grpc.GreeterStub(channel)
 
     for reply in stub.lots_of_replies(
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/python/grpc-support.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/python/grpc-support.md
index a144babf3f..dd2bb93f70 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/python/grpc-support.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/guide/python/grpc-support.md
@@ -27,9 +27,9 @@ Fory 可以为包含 service 定义的 schema 生成 Python gRPC companion modul
 message bytes,请使用标准 protobuf gRPC 代码生成。
 
 当前生成的 Python companion 面向同步 `grpcio` API。请使用普通 `def` servicer 方法、
-`grpc.server(...)`、`grpc.insecure_channel(...)`,并用 Python iterator/generator 处理
-streaming RPC。Compiler 不会生成 `grpc.aio` stub 或 service base,因此不要把生成 servicer
-方法实现成 `async def`,除非你在生成 companion 外自行封装 adapter。
+`grpc.server(...)`、标准 `grpc.Channel` 实例,并用 Python iterator/generator 处理 
streaming RPC。
+生成的 stub 可以接收应用自行配置的任意 channel。Compiler 不会生成 `grpc.aio` stub 或 service
+base,因此不要把生成 servicer 方法实现成 `async def`,除非你在生成 companion 外自行封装 adapter。
 
 ## 添加依赖
 
@@ -112,7 +112,8 @@ import demo_greeter_grpc
 
 
 def main():
-    with grpc.insecure_channel("localhost:50051") as channel:
+    credentials = grpc.ssl_channel_credentials()
+    with grpc.secure_channel("api.example.com:443", credentials) as channel:
         stub = demo_greeter_grpc.GreeterStub(channel)
         reply = stub.say_hello(demo_greeter.HelloRequest(name="Fory"))
         print(reply.reply)
@@ -170,7 +171,8 @@ class Greeter(demo_greeter_grpc.GreeterServicer):
 生成的 client 使用标准 `grpcio` streaming 调用形态:
 
 ```python
-with grpc.insecure_channel("localhost:50051") as channel:
+credentials = grpc.ssl_channel_credentials()
+with grpc.secure_channel("api.example.com:443", credentials) as channel:
     stub = demo_greeter_grpc.GreeterStub(channel)
 
     for reply in stub.lots_of_replies(
diff --git 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2.0/guide/python/grpc-support.md
 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2.0/guide/python/grpc-support.md
index a144babf3f..dd2bb93f70 100644
--- 
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2.0/guide/python/grpc-support.md
+++ 
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.2.0/guide/python/grpc-support.md
@@ -27,9 +27,9 @@ Fory 可以为包含 service 定义的 schema 生成 Python gRPC companion modul
 message bytes,请使用标准 protobuf gRPC 代码生成。
 
 当前生成的 Python companion 面向同步 `grpcio` API。请使用普通 `def` servicer 方法、
-`grpc.server(...)`、`grpc.insecure_channel(...)`,并用 Python iterator/generator 处理
-streaming RPC。Compiler 不会生成 `grpc.aio` stub 或 service base,因此不要把生成 servicer
-方法实现成 `async def`,除非你在生成 companion 外自行封装 adapter。
+`grpc.server(...)`、标准 `grpc.Channel` 实例,并用 Python iterator/generator 处理 
streaming RPC。
+生成的 stub 可以接收应用自行配置的任意 channel。Compiler 不会生成 `grpc.aio` stub 或 service
+base,因此不要把生成 servicer 方法实现成 `async def`,除非你在生成 companion 外自行封装 adapter。
 
 ## 添加依赖
 
@@ -112,7 +112,8 @@ import demo_greeter_grpc
 
 
 def main():
-    with grpc.insecure_channel("localhost:50051") as channel:
+    credentials = grpc.ssl_channel_credentials()
+    with grpc.secure_channel("api.example.com:443", credentials) as channel:
         stub = demo_greeter_grpc.GreeterStub(channel)
         reply = stub.say_hello(demo_greeter.HelloRequest(name="Fory"))
         print(reply.reply)
@@ -170,7 +171,8 @@ class Greeter(demo_greeter_grpc.GreeterServicer):
 生成的 client 使用标准 `grpcio` streaming 调用形态:
 
 ```python
-with grpc.insecure_channel("localhost:50051") as channel:
+credentials = grpc.ssl_channel_credentials()
+with grpc.secure_channel("api.example.com:443", credentials) as channel:
     stub = demo_greeter_grpc.GreeterStub(channel)
 
     for reply in stub.lots_of_replies(
diff --git a/versioned_docs/version-1.2.0/guide/python/grpc-support.md 
b/versioned_docs/version-1.2.0/guide/python/grpc-support.md
index 946602be30..65db689e63 100644
--- a/versioned_docs/version-1.2.0/guide/python/grpc-support.md
+++ b/versioned_docs/version-1.2.0/guide/python/grpc-support.md
@@ -29,8 +29,9 @@ encoding. Use standard protobuf gRPC code generation when 
clients or tools must
 consume protobuf message bytes directly.
 
 Generated Python companions currently target the synchronous `grpcio` API. Use
-regular `def` servicer methods, `grpc.server(...)`, 
`grpc.insecure_channel(...)`,
-and Python iterators or generators for streaming RPCs. The compiler does not
+regular `def` servicer methods, `grpc.server(...)`, standard `grpc.Channel`
+instances, and Python iterators or generators for streaming RPCs. The generated
+stub accepts any channel configured by your application. The compiler does not
 generate `grpc.aio` stubs or service bases, so do not implement generated
 servicer methods as `async def` unless you add a custom adapter outside the
 generated companion.
@@ -129,7 +130,8 @@ import demo_greeter_grpc
 
 
 def main():
-    with grpc.insecure_channel("localhost:50051") as channel:
+    credentials = grpc.ssl_channel_credentials()
+    with grpc.secure_channel("api.example.com:443", credentials) as channel:
         stub = demo_greeter_grpc.GreeterStub(channel)
         reply = stub.say_hello(demo_greeter.HelloRequest(name="Fory"))
         print(reply.reply)
@@ -188,7 +190,8 @@ class Greeter(demo_greeter_grpc.GreeterServicer):
 Generated clients use the standard `grpcio` streaming call shapes:
 
 ```python
-with grpc.insecure_channel("localhost:50051") as channel:
+credentials = grpc.ssl_channel_credentials()
+with grpc.secure_channel("api.example.com:443", credentials) as channel:
     stub = demo_greeter_grpc.GreeterStub(channel)
 
     for reply in stub.lots_of_replies(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to