larrythecoder / grpc
PHP 的 gRPC 库
1.57.1
2023-09-05 19:16 UTC
Requires
- php: >=7.1
- sof3/await-generator: ^3.6
Requires (Dev)
- google/auth: ^v1.3.0
Suggests
- ext-protobuf: For better performance, install the protobuf C extension.
- google/protobuf: To get started using grpc quickly, install the native protobuf library.
README
PHP gRPC 实现异步调用的非官方工作。实现来自 @arnaud-lb 的 php-async 分支。
以下是与我的 grpc 绑定库 交互的文档。
异步调用
PHP 没有事件循环,因此需要用户空间事件循环来检查调用是否完成。以下内容需要定期调用
Call::drainCompletionQueue(PHP_INT_MIN);
第一个参数指定了等待任何队列完成的超时时间。在这种情况下,完成队列将检查 任何调用是否完成一次。
客户端 gRPC 调用
要建立双向调用,用户必须在发送任何消息之前等待与远程服务器的连接建立。这可以通过向 ClientCallInterface::onClientReady(Closure)
提供回调来实现。或者,可以使用 ClientCallInterface::isReady()
来检查调用是否准备好向远程服务器发送任何消息。