gRPC client to be used by ext_proc filter#14283
Conversation
44a439b to
cbe129f
Compare
The ext_proc filter will use this set of classes to abstract handling the gRPC stream it'll use to talk to the remote server. Signed-off-by: Gregory Brail <gregbrail@google.com>
htuch
left a comment
There was a problem hiding this comment.
Exciting to see the implementation arriving :) Mostly just some Envoy-style comments..
/wait
| public: | ||
| virtual ~ExternalProcessorCallbacks() = default; | ||
| virtual void onReceiveMessage( | ||
| std::unique_ptr<envoy::service::ext_proc::v3alpha::ProcessingResponse>&& response) = 0; |
There was a problem hiding this comment.
Nit: prefer using PURE in Envoy style
| : callbacks_(callbacks) { | ||
| client_ = std::move(client); | ||
| auto descriptor = Protobuf::DescriptorPool::generated_pool()->FindMethodByName(kExternalMethod); | ||
| assert(descriptor != nullptr); |
There was a problem hiding this comment.
No need for an assert here, since it will crash immediately if not true. Also, we don't use lower case assert in Envoy, prefer ASSERT, RELEASE_ASSERT or `ENVOY_BUG.
There was a problem hiding this comment.
Ack. No assert needed for now then.
|
|
||
| using ExternalProcessorStreamPtr = std::unique_ptr<ExternalProcessorStream>; | ||
|
|
||
| class ExternalProcessorCallbacks { |
There was a problem hiding this comment.
Does this wrapper layer give you much over the existing stream callbacks? Maybe you are planning on doing more in here later?
There was a problem hiding this comment.
Good point. In general I wanted to have a clean abstraction to ease unit testing. One difference is that I don't think that we'll be needing to handle the metadata callbacks and this abstraction takes care of them for me.
| Grpc::Status::GrpcStatus grpc_status_ = Grpc::Status::WellKnownGrpcStatus::Ok; | ||
| bool grpc_closed_ = false; | ||
|
|
||
| std::unique_ptr<ExternalProcessorClientImpl> client_; |
There was a problem hiding this comment.
Nit: we usually setup an alias with using ExternalProcessClientImplPtr = std::unique.. for these smart pointer types in Envoy.
| static constexpr char kExternalMethod[] = | ||
| "envoy.service.ext_proc.v3alpha.ExternalProcessor.Process"; | ||
|
|
||
| ExternalProcessorClientImpl::ExternalProcessorClientImpl( |
There was a problem hiding this comment.
FYI, we're going to want to have a thread-local cache of aync clients for ext_proc similar to what is done for the gRPC access loggers and ext_authz. This is what I referenced in my comment on your doc a while back. But, I'm hoping that we can land #12598 soon to avoid you needing to have to do this explicitly.
There was a problem hiding this comment.
I see that in the ext_authz filter and I was planning to first get the basic thing working and then add that. However I'm watching that PR and if it comes in soon, then even better.
Signed-off-by: Gregory Brail <gregbrail@google.com>
| ) | ||
|
|
||
| envoy_cc_library( | ||
| name = "client_impl", |
There was a problem hiding this comment.
Nit: Envoy convention is typically client_lib.
| TEST_F(ExtProcStreamTest, SendToStream) { | ||
| auto stream = client_->start(*this, 200ms); | ||
| // Send something and ensure that we get it. Doesn't really matter what. | ||
| EXPECT_CALL(stream_, sendMessageRaw_(_, false)).Times(1); |
Signed-off-by: Gregory Brail <gregbrail@google.com>
|
Ready, I think, but Azure won't let me re-run the failed ARM build. |
| auto stream = client_->start(*this, 200ms); | ||
| // Send something and ensure that we get it. Doesn't really matter what. | ||
| EXPECT_CALL(stream_, sendMessageRaw_(_, false)).Times(1); | ||
| EXPECT_CALL(stream_, sendMessageRaw_(_, false)); |
There was a problem hiding this comment.
Lots more of these in this PR, but I actually think I should just add a format check for this and stop harassing people :)
* master: buffer: Optimize the layout of Slices in Buffer::OwnedImpl by removing subclassing and storing slice info directly in the SliceDeque (envoyproxy#14282) gRPC client to be used by ext_proc filter (envoyproxy#14283) http2: Add integration tests for PRIORITY frame flood mitigation for upstream servers (envoyproxy#14328) event: touch watchdog before execution of each post callback and before deferred deletion (envoyproxy#14339) stale: more allowed ops (envoyproxy#14345) stale: more changes (envoyproxy#14344) test: TODO fixup making enable_half_close private envoyproxy#14330) event: Reduce potential for lock contention while executing dispatcher post callbacks. (envoyproxy#14289) stale: fix config (envoyproxy#14337) metrics service sink: generalize the sink and grpc streamer for external use (envoyproxy#13919) wasm: update V8 to v8.8.278.8. (envoyproxy#14298) repo: switch to actions based stale bot (envoyproxy#14335) buffer: Use WatermarkFactory to create most WatermarkBuffer instances (envoyproxy#14256) Signed-off-by: Michael Puncel <mpuncel@squareup.com>
This is a set of classes that the ext_proc server will use to abstract talking to the remote server via a gRPC stream.