|
12 | 12 | import io.envoyproxy.envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor; |
13 | 13 | import io.envoyproxy.envoy.service.ext_proc.v3.ExternalProcessorGrpc; |
14 | 14 | import io.envoyproxy.envoy.service.ext_proc.v3.ProcessingRequest; |
| 15 | +import io.envoyproxy.envoy.service.ext_proc.v3.ProcessingResponse; |
15 | 16 | import io.grpc.CallOptions; |
16 | 17 | import io.grpc.Channel; |
17 | 18 | import io.grpc.ClientCall; |
@@ -220,14 +221,20 @@ public void start(Listener<RespT> responseListener, Metadata headers) { |
220 | 221 | this.requestHeaders = headers; |
221 | 222 | ExternalProcessorInterceptor.ExtProcListener<ReqT, RespT> wrappedListener = new ExternalProcessorInterceptor.ExtProcListener<>(responseListener, delegate(), method, this); |
222 | 223 |
|
223 | | - requestObserver = stub.process(new io.grpc.stub.StreamObserver<io.envoyproxy.envoy.service.ext_proc.v3.ProcessingResponse>() { |
| 224 | + requestObserver = stub.process(new io.grpc.stub.StreamObserver<ProcessingResponse>() { |
224 | 225 | @Override |
225 | 226 | public void onNext(io.envoyproxy.envoy.service.ext_proc.v3.ProcessingResponse response) { |
226 | 227 | if (response.hasImmediateResponse()) { |
227 | 228 | handleImmediateResponse(response.getImmediateResponse(), responseListener); |
228 | 229 | return; |
229 | 230 | } |
230 | 231 |
|
| 232 | + if (response.getRequestDrain()) { |
| 233 | + handleFailOpen(wrappedListener); |
| 234 | + requestObserver.onCompleted(); |
| 235 | + return; |
| 236 | + } |
| 237 | + |
231 | 238 | // --- Handlers for 6 Event types --- |
232 | 239 |
|
233 | 240 | // 1. Client Headers |
@@ -535,7 +542,21 @@ void unblockAfterStreamComplete() { |
535 | 542 |
|
536 | 543 | @VisibleForTesting |
537 | 544 | ExternalProcessorGrpc.ExternalProcessorStub getExternalProcessorStub(GrpcService service) { |
538 | | - return null; // Implementation needed |
| 545 | + // TODO: Implement actual stub creation based on the GrpcService configuration. |
| 546 | + // This will likely involve creating a ManagedChannel and then a stub from it. |
| 547 | + // For now, returning null as a placeholder. |
| 548 | + // |
| 549 | + // This method needs to create a ManagedChannel based on the GrpcService configuration. |
| 550 | + // The GrpcService contains information like target URI, timeout, and optionally |
| 551 | + // a Google gRPC service config. |
| 552 | + // For a full implementation, you would typically use a ManagedChannelBuilder |
| 553 | + // to construct the channel and then create a stub from it. |
| 554 | + // Example (simplified, actual implementation would need more details from GrpcService): |
| 555 | + // ManagedChannel channel = ManagedChannelBuilder.forTarget(service.getEnvoyGrpc().getClusterName()) |
| 556 | + // .usePlaintext() // Or use TLS based on configuration |
| 557 | + // .build(); |
| 558 | + // return ExternalProcessorGrpc.newStub(channel); |
| 559 | + return null; |
539 | 560 | } |
540 | 561 | } |
541 | 562 | } |
0 commit comments