From d9a5c254de21e7c89b57342d68f310d6e2a23fa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E6=B3=BD=E8=BD=A9?= Date: Thu, 31 Oct 2024 13:57:56 +0800 Subject: [PATCH] fix: previous error log is too strict (#788) Signed-off-by: spacewander --- api/pkg/filtermanager/filtermanager.go | 12 +- api/tests/integration/consumer_test.go | 51 ++++++ api/tests/integration/test_plugins.go | 43 +++++ .../testdata/services/grpc/sample.pb.go | 169 +++++++++++------- .../developer-guide/plugin_development.md | 2 +- .../developer-guide/plugin_development.md | 2 +- 6 files changed, 204 insertions(+), 75 deletions(-) diff --git a/api/pkg/filtermanager/filtermanager.go b/api/pkg/filtermanager/filtermanager.go index 862d305a..c86546f6 100644 --- a/api/pkg/filtermanager/filtermanager.go +++ b/api/pkg/filtermanager/filtermanager.go @@ -195,11 +195,13 @@ func FilterManagerFactory(c interface{}, cb capi.FilterCallbackHandler) (streamF api.LogErrorf("plugin %s has DecodeRequest but not DecodeHeaders. To run DecodeRequest, we need to return api.WaitAllData from DecodeHeaders", fc.Name) } - p := pkgPlugins.LoadPluginType(fc.Name) - if p != nil { - order := p.Order() - if order.Position <= pkgPlugins.OrderPositionAuthn { - api.LogErrorf("plugin %s has DecodeRequest which is not supported because the order of plugin", fc.Name) + if conf.consumerFiltersEndAt != 0 { + p := pkgPlugins.LoadPluginType(fc.Name) + if p != nil { + order := p.Order() + if order.Position <= pkgPlugins.OrderPositionAuthn { + api.LogErrorf("plugin %s has DecodeRequest which is not supported because the order of plugin", fc.Name) + } } } } diff --git a/api/tests/integration/consumer_test.go b/api/tests/integration/consumer_test.go index a8152d0f..a367fe68 100644 --- a/api/tests/integration/consumer_test.go +++ b/api/tests/integration/consumer_test.go @@ -225,3 +225,54 @@ func TestConsumerFilterNotAfterConsumerRunInLaterPhase(t *testing.T) { }) } } + +func TestConsumerFilterNotAfterConsumerRunDecodeRequest(t *testing.T) { + dp, err := dataplane.StartDataPlane(t, &dataplane.Option{ + Bootstrap: dataplane.Bootstrap().AddConsumer("marvin", map[string]interface{}{ + "auth": map[string]interface{}{ + "consumer": `{"name":"marvin"}`, + }, + }), + NoErrorLogCheck: true, + ExpectLogPattern: []string{ + `plugin beforeConsumerAndHasDecodeRequest has DecodeRequest which is not supported because the order of plugin`, + }, + }) + if err != nil { + t.Fatalf("failed to start data plane: %v", err) + return + } + defer dp.Stop() + + tests := []struct { + name string + config *filtermanager.FilterManagerConfig + run func(t *testing.T) + }{ + { + name: "authn & exec", + config: controlplane.NewPluginConfig([]*model.FilterConfig{ + { + Name: "beforeConsumerAndHasDecodeRequest", + Config: map[string]interface{}{}, + }, + { + Name: "consumer", + Config: map[string]interface{}{}, + }, + }), + run: func(t *testing.T) { + resp, _ := dp.Get("/echo", http.Header{"Authorization": []string{"marvin"}}) + assert.Equal(t, 200, resp.StatusCode) + assert.Equal(t, []string{"beforeConsumerAndHasDecodeRequest"}, resp.Header.Values("Echo-Run")) + }, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + controlPlane.UseGoPluginConfig(t, tt.config, dp) + tt.run(t) + }) + } +} diff --git a/api/tests/integration/test_plugins.go b/api/tests/integration/test_plugins.go index 9fe9359d..7245af38 100644 --- a/api/tests/integration/test_plugins.go +++ b/api/tests/integration/test_plugins.go @@ -532,6 +532,48 @@ func (f *beforeConsumerAndHasOtherMethodFilter) EncodeHeaders(headers api.Respon return api.Continue } +type beforeConsumerAndHasDecodeRequestPlugin struct { + plugins.PluginMethodDefaultImpl +} + +func (p *beforeConsumerAndHasDecodeRequestPlugin) Order() plugins.PluginOrder { + return plugins.PluginOrder{ + Position: plugins.OrderPositionAccess, + } +} + +func (p *beforeConsumerAndHasDecodeRequestPlugin) Config() api.PluginConfig { + return &Config{} +} + +func (p *beforeConsumerAndHasDecodeRequestPlugin) Factory() api.FilterFactory { + return beforeConsumerAndHasDecodeRequestFactory +} + +func beforeConsumerAndHasDecodeRequestFactory(c interface{}, callbacks api.FilterCallbackHandler) api.Filter { + return &beforeConsumerAndHasDecodeRequestFilter{ + callbacks: callbacks, + config: c.(*Config), + } +} + +type beforeConsumerAndHasDecodeRequestFilter struct { + api.PassThroughFilter + + callbacks api.FilterCallbackHandler + config *Config +} + +func (f *beforeConsumerAndHasDecodeRequestFilter) DecodeHeaders(headers api.RequestHeaderMap, endStream bool) api.ResultAction { + headers.Add("run", "beforeConsumerAndHasDecodeRequest") + return api.Continue +} + +func (f *beforeConsumerAndHasDecodeRequestFilter) DecodeRequest(headers api.RequestHeaderMap, data api.BufferInstance, trailers api.RequestTrailerMap) api.ResultAction { + headers.Add("run", "beforeConsumerAndHasDecodeRequest:DecodeRequest") + return api.Continue +} + type onLogPlugin struct { plugins.PluginMethodDefaultImpl } @@ -587,5 +629,6 @@ func init() { plugins.RegisterPlugin("benchmark", &benchmarkPlugin{}) plugins.RegisterPlugin("benchmark2", &benchmarkPlugin{}) plugins.RegisterPlugin("beforeConsumerAndHasOtherMethod", &beforeConsumerAndHasOtherMethodPlugin{}) + plugins.RegisterPlugin("beforeConsumerAndHasDecodeRequest", &beforeConsumerAndHasDecodeRequestPlugin{}) plugins.RegisterPlugin("onLog", &onLogPlugin{}) } diff --git a/api/tests/integration/testdata/services/grpc/sample.pb.go b/api/tests/integration/testdata/services/grpc/sample.pb.go index 1d87c9b1..c9e75689 100644 --- a/api/tests/integration/testdata/services/grpc/sample.pb.go +++ b/api/tests/integration/testdata/services/grpc/sample.pb.go @@ -1,8 +1,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.35.1 +// protoc-gen-go v1.31.0 // protoc v4.24.4 -// source: sample.proto +// source: api/tests/integration/testdata/services/grpc/sample.proto package main @@ -31,9 +31,11 @@ type HelloRequest struct { func (x *HelloRequest) Reset() { *x = HelloRequest{} - mi := &file_sample_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *HelloRequest) String() string { @@ -43,8 +45,8 @@ func (x *HelloRequest) String() string { func (*HelloRequest) ProtoMessage() {} func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_sample_proto_msgTypes[0] - if x != nil { + mi := &file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -56,7 +58,7 @@ func (x *HelloRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_sample_proto_rawDescGZIP(), []int{0} + return file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescGZIP(), []int{0} } func (x *HelloRequest) GetName() string { @@ -76,9 +78,11 @@ type HelloResponse struct { func (x *HelloResponse) Reset() { *x = HelloResponse{} - mi := &file_sample_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) + if protoimpl.UnsafeEnabled { + mi := &file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } func (x *HelloResponse) String() string { @@ -88,8 +92,8 @@ func (x *HelloResponse) String() string { func (*HelloResponse) ProtoMessage() {} func (x *HelloResponse) ProtoReflect() protoreflect.Message { - mi := &file_sample_proto_msgTypes[1] - if x != nil { + mi := &file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -101,7 +105,7 @@ func (x *HelloResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use HelloResponse.ProtoReflect.Descriptor instead. func (*HelloResponse) Descriptor() ([]byte, []int) { - return file_sample_proto_rawDescGZIP(), []int{1} + return file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescGZIP(), []int{1} } func (x *HelloResponse) GetMessage() string { @@ -111,60 +115,63 @@ func (x *HelloResponse) GetMessage() string { return "" } -var File_sample_proto protoreflect.FileDescriptor - -var file_sample_proto_rawDesc = []byte{ - 0x0a, 0x0c, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2c, - 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, - 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x29, 0x0a, 0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x94, 0x02, 0x0a, 0x06, - 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x12, 0x85, 0x01, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, - 0x6c, 0x6c, 0x6f, 0x12, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x3b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, - 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, - 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x48, - 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x81, - 0x01, 0x0a, 0x04, 0x4f, 0x75, 0x63, 0x68, 0x12, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, - 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, - 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, - 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, - 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, - 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, - 0x70, 0x63, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0x40, 0x5a, 0x3e, 0x6d, 0x6f, 0x73, 0x6e, 0x2e, 0x69, 0x6f, 0x2f, 0x68, 0x74, - 0x6e, 0x6e, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x69, 0x6e, 0x74, - 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, - 0x61, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, - 0x6d, 0x61, 0x69, 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +var File_api_tests_integration_testdata_services_grpc_sample_proto protoreflect.FileDescriptor + +var file_api_tests_integration_testdata_services_grpc_sample_proto_rawDesc = []byte{ + 0x0a, 0x39, 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, + 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, + 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x73, + 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x2c, 0x61, 0x70, 0x69, + 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65, 0x6c, + 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x29, 0x0a, + 0x0d, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x94, 0x02, 0x0a, 0x06, 0x53, 0x61, 0x6d, + 0x70, 0x6c, 0x65, 0x12, 0x85, 0x01, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, + 0x12, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, + 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x3b, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x65, + 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x65, 0x6c, 0x6c, + 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x81, 0x01, 0x0a, 0x04, + 0x4f, 0x75, 0x63, 0x68, 0x12, 0x3a, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, + 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, + 0x74, 0x64, 0x61, 0x74, 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, + 0x72, 0x70, 0x63, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x3b, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, + 0x61, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x40, 0x5a, 0x3e, 0x6d, 0x6f, 0x73, 0x6e, 0x2e, 0x69, 0x6f, 0x2f, 0x68, 0x74, 0x6e, 0x6e, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x67, 0x72, + 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x73, + 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x6d, 0x61, 0x69, + 0x6e, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( - file_sample_proto_rawDescOnce sync.Once - file_sample_proto_rawDescData = file_sample_proto_rawDesc + file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescOnce sync.Once + file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescData = file_api_tests_integration_testdata_services_grpc_sample_proto_rawDesc ) -func file_sample_proto_rawDescGZIP() []byte { - file_sample_proto_rawDescOnce.Do(func() { - file_sample_proto_rawDescData = protoimpl.X.CompressGZIP(file_sample_proto_rawDescData) +func file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescGZIP() []byte { + file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescOnce.Do(func() { + file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescData) }) - return file_sample_proto_rawDescData + return file_api_tests_integration_testdata_services_grpc_sample_proto_rawDescData } -var file_sample_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_sample_proto_goTypes = []any{ +var file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_api_tests_integration_testdata_services_grpc_sample_proto_goTypes = []interface{}{ (*HelloRequest)(nil), // 0: api.tests.integration.testdata.services.grpc.HelloRequest (*HelloResponse)(nil), // 1: api.tests.integration.testdata.services.grpc.HelloResponse } -var file_sample_proto_depIdxs = []int32{ +var file_api_tests_integration_testdata_services_grpc_sample_proto_depIdxs = []int32{ 0, // 0: api.tests.integration.testdata.services.grpc.Sample.SayHello:input_type -> api.tests.integration.testdata.services.grpc.HelloRequest 0, // 1: api.tests.integration.testdata.services.grpc.Sample.Ouch:input_type -> api.tests.integration.testdata.services.grpc.HelloRequest 1, // 2: api.tests.integration.testdata.services.grpc.Sample.SayHello:output_type -> api.tests.integration.testdata.services.grpc.HelloResponse @@ -176,27 +183,53 @@ var file_sample_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for field type_name } -func init() { file_sample_proto_init() } -func file_sample_proto_init() { - if File_sample_proto != nil { +func init() { file_api_tests_integration_testdata_services_grpc_sample_proto_init() } +func file_api_tests_integration_testdata_services_grpc_sample_proto_init() { + if File_api_tests_integration_testdata_services_grpc_sample_proto != nil { return } + if !protoimpl.UnsafeEnabled { + file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_sample_proto_rawDesc, + RawDescriptor: file_api_tests_integration_testdata_services_grpc_sample_proto_rawDesc, NumEnums: 0, NumMessages: 2, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_sample_proto_goTypes, - DependencyIndexes: file_sample_proto_depIdxs, - MessageInfos: file_sample_proto_msgTypes, + GoTypes: file_api_tests_integration_testdata_services_grpc_sample_proto_goTypes, + DependencyIndexes: file_api_tests_integration_testdata_services_grpc_sample_proto_depIdxs, + MessageInfos: file_api_tests_integration_testdata_services_grpc_sample_proto_msgTypes, }.Build() - File_sample_proto = out.File - file_sample_proto_rawDesc = nil - file_sample_proto_goTypes = nil - file_sample_proto_depIdxs = nil + File_api_tests_integration_testdata_services_grpc_sample_proto = out.File + file_api_tests_integration_testdata_services_grpc_sample_proto_rawDesc = nil + file_api_tests_integration_testdata_services_grpc_sample_proto_goTypes = nil + file_api_tests_integration_testdata_services_grpc_sample_proto_depIdxs = nil } diff --git a/site/content/en/docs/developer-guide/plugin_development.md b/site/content/en/docs/developer-guide/plugin_development.md index c064321d..35f1c227 100644 --- a/site/content/en/docs/developer-guide/plugin_development.md +++ b/site/content/en/docs/developer-guide/plugin_development.md @@ -143,7 +143,7 @@ The same process applies to the Encode path in a reverse order, and the method i Note: `EncodeResponse` is only executed if `EncodeHeaders` returns `WaitAllData`. So if `EncodeResponse` is defined, `EncodeHeaders` must be defined as well. When both `EncodeResponse` and `EncodeData/EncodeTrailers` are defined in the plugin: if `EncodeHeaders` returns `WaitAllData`, only `EncodeResponse` is executed, otherwise, only `EncodeData/EncodeTrailers` is executed. -Currently, `DecodeRequest` is not supported by plugins whose order is `Access` or `Authn`. +Currently, if Consumer plugins are configured, `DecodeRequest` is not supported by plugins whose order is `Access` or `Authn`. ## Consumer Plugins diff --git a/site/content/zh-hans/docs/developer-guide/plugin_development.md b/site/content/zh-hans/docs/developer-guide/plugin_development.md index 75787ec5..26f3c4c9 100644 --- a/site/content/zh-hans/docs/developer-guide/plugin_development.md +++ b/site/content/zh-hans/docs/developer-guide/plugin_development.md @@ -138,7 +138,7 @@ filter manager 实现了以下特性: 注意:`EncodeResponse` 仅在 `EncodeHeaders` 返回 `WaitAllData` 时才被执行。所以如果定义了 `EncodeResponse`,一定要定义 `EncodeHeaders`。当插件里同时定义了 `EncodeResponse` 和 `EncodeData/EncodeTrailers`:如果 `EncodeHeaders` 返回 `WaitAllData`,只有 `EncodeResponse` 会运行,否则只有 `EncodeData/EncodeTrailers` 会运行。 -目前顺序为 `Access` 或 `Authn` 的插件不支持 `DecodeRequest` 方法。 +目前如果配置了消费者插件,顺序为 `Access` 或 `Authn` 的插件的 `DecodeRequest` 方法将不会被执行。 ## 消费者插件