@@ -34,6 +34,7 @@ This package provides complete Laravel integration with RoadRunner, offering:
3434 - [ HTTP Plugin] ( #http-plugin )
3535 - [ Jobs (Queue) Plugin] ( #jobs-queue-plugin )
3636 - [ gRPC Plugin] ( #grpc-plugin )
37+ - [ gRPC Client] ( #grpc-client )
3738 - [ Temporal] ( #temporal )
3839- [ Custom Workers] ( #custom-workers )
3940- [ Support] ( #support )
@@ -219,6 +220,66 @@ return [
219220];
220221` ` `
221222
223+ # ### gRPC Client Usage
224+
225+ The package also allows your Laravel application to act as a gRPC client, making requests to external gRPC services.
226+
227+ # #### Client Configuration
228+
229+ Add your gRPC client configuration to `config/roadrunner.php` :
230+
231+ ` ` ` php
232+ return [
233+ // ... other configuration
234+ 'grpc' => [
235+ // ... server config
236+ 'clients' => [
237+ 'services' => [
238+ [
239+ 'connection' => '127.0.0.1:9001', // gRPC server address
240+ 'interfaces' => [
241+ \A pp\G rpc\E choServiceInterface::class,
242+ ],
243+ // 'tls' => [ ... ] // Optional TLS configuration
244+ ],
245+ ],
246+ // 'interceptors' => [ ... ] // Optional interceptors
247+ ],
248+ ],
249+ ];
250+ ` ` `
251+
252+ # #### Using the gRPC Client in Laravel
253+
254+ You can inject `Spiral\Grpc\Client\ServiceClientProvider` into your services or controllers to obtain a gRPC client instance :
255+
256+ ` ` ` php
257+ use Spiral\G rpc\C lient\S erviceClientProvider;
258+ use App\G rpc\E choServiceInterface;
259+ use App\G rpc\E choRequest;
260+
261+ class GrpcController extends Controller
262+ {
263+ public function callService(ServiceClientProvider $provider)
264+ {
265+ /** @var EchoServiceInterface $client */
266+ $client = $provider->get(EchoServiceInterface::class);
267+
268+ $request = new EchoRequest();
269+ $request->setMessage('Hello from client!');
270+
271+ $response = $client->Echo($request);
272+
273+ return $response->getMessage();
274+ }
275+ }
276+ ` ` `
277+
278+ > **Note:**
279+ > - Make sure you have generated the PHP classes from your `.proto` files (using `protoc`).
280+ > - The `connection` and `interfaces` must match the service you want to call.
281+ > - You can configure multiple gRPC client services as needed.
282+
222283# ## Temporal
223284
224285Temporal is a workflow engine that enables orchestration of microservices and provides sophisticated workflow
0 commit comments