Skip to content

Commit 92cc956

Browse files
authored
Merge pull request #1853 from murgatroid99/grpc-js-xds_http_filters
grpc-js-xds: Add HTTP Filters support
2 parents 0025df4 + 215cdcd commit 92cc956

23 files changed

+675
-64
lines changed

packages/grpc-js-xds/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"prepare": "npm run compile",
1313
"pretest": "npm run compile",
1414
"posttest": "npm run check",
15-
"generate-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --includeComments --includeDirs deps/envoy-api/ deps/udpa/ deps/googleapis/ deps/protoc-gen-validate/ -O src/generated/ --grpcLib @grpc/grpc-js envoy/service/discovery/v2/ads.proto envoy/service/load_stats/v2/lrs.proto envoy/service/discovery/v3/ads.proto envoy/service/load_stats/v3/lrs.proto envoy/config/listener/v3/listener.proto envoy/config/route/v3/route.proto envoy/config/cluster/v3/cluster.proto envoy/config/endpoint/v3/endpoint.proto envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto",
15+
"generate-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --includeComments --includeDirs deps/envoy-api/ deps/udpa/ deps/googleapis/ deps/protoc-gen-validate/ -O src/generated/ --grpcLib @grpc/grpc-js envoy/service/discovery/v2/ads.proto envoy/service/load_stats/v2/lrs.proto envoy/service/discovery/v3/ads.proto envoy/service/load_stats/v3/lrs.proto envoy/config/listener/v3/listener.proto envoy/config/route/v3/route.proto envoy/config/cluster/v3/cluster.proto envoy/config/endpoint/v3/endpoint.proto envoy/extensions/filters/network/http_connection_manager/v3/http_connection_manager.proto udpa/type/v1/typed_struct.proto",
1616
"generate-interop-types": "proto-loader-gen-types --keep-case --longs String --enums String --defaults --oneofs --json --includeComments --includeDirs proto/ -O interop/generated --grpcLib @grpc/grpc-js grpc/testing/test.proto"
1717
},
1818
"repository": {

packages/grpc-js-xds/src/environment.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*
16-
*/
16+
*/
17+
18+
export const EXPERIMENTAL_FAULT_INJECTION = process.env.GRPC_XDS_EXPERIMENTAL_FAULT_INJECTION;
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
// Original file: null
22

33
import type { UninterpretedOption as _google_protobuf_UninterpretedOption, UninterpretedOption__Output as _google_protobuf_UninterpretedOption__Output } from '../../google/protobuf/UninterpretedOption';
4-
import type { MigrateAnnotation as _udpa_annotations_MigrateAnnotation, MigrateAnnotation__Output as _udpa_annotations_MigrateAnnotation__Output } from '../../udpa/annotations/MigrateAnnotation';
54

65
export interface EnumOptions {
76
'allowAlias'?: (boolean);
87
'deprecated'?: (boolean);
98
'uninterpretedOption'?: (_google_protobuf_UninterpretedOption)[];
10-
'.udpa.annotations.enum_migrate'?: (_udpa_annotations_MigrateAnnotation);
119
}
1210

1311
export interface EnumOptions__Output {
1412
'allowAlias': (boolean);
1513
'deprecated': (boolean);
1614
'uninterpretedOption': (_google_protobuf_UninterpretedOption__Output)[];
17-
'.udpa.annotations.enum_migrate'?: (_udpa_annotations_MigrateAnnotation__Output);
1815
}
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
// Original file: null
22

33
import type { UninterpretedOption as _google_protobuf_UninterpretedOption, UninterpretedOption__Output as _google_protobuf_UninterpretedOption__Output } from '../../google/protobuf/UninterpretedOption';
4-
import type { MigrateAnnotation as _udpa_annotations_MigrateAnnotation, MigrateAnnotation__Output as _udpa_annotations_MigrateAnnotation__Output } from '../../udpa/annotations/MigrateAnnotation';
54

65
export interface EnumValueOptions {
76
'deprecated'?: (boolean);
87
'uninterpretedOption'?: (_google_protobuf_UninterpretedOption)[];
9-
'.envoy.annotations.disallowed_by_default_enum'?: (boolean);
10-
'.udpa.annotations.enum_value_migrate'?: (_udpa_annotations_MigrateAnnotation);
118
}
129

1310
export interface EnumValueOptions__Output {
1411
'deprecated': (boolean);
1512
'uninterpretedOption': (_google_protobuf_UninterpretedOption__Output)[];
16-
'.envoy.annotations.disallowed_by_default_enum': (boolean);
17-
'.udpa.annotations.enum_value_migrate'?: (_udpa_annotations_MigrateAnnotation__Output);
1813
}

packages/grpc-js-xds/src/generated/google/protobuf/FieldOptions.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import type { UninterpretedOption as _google_protobuf_UninterpretedOption, UninterpretedOption__Output as _google_protobuf_UninterpretedOption__Output } from '../../google/protobuf/UninterpretedOption';
44
import type { FieldRules as _validate_FieldRules, FieldRules__Output as _validate_FieldRules__Output } from '../../validate/FieldRules';
5-
import type { FieldSecurityAnnotation as _udpa_annotations_FieldSecurityAnnotation, FieldSecurityAnnotation__Output as _udpa_annotations_FieldSecurityAnnotation__Output } from '../../udpa/annotations/FieldSecurityAnnotation';
6-
import type { FieldMigrateAnnotation as _udpa_annotations_FieldMigrateAnnotation, FieldMigrateAnnotation__Output as _udpa_annotations_FieldMigrateAnnotation__Output } from '../../udpa/annotations/FieldMigrateAnnotation';
75

86
// Original file: null
97

@@ -30,10 +28,6 @@ export interface FieldOptions {
3028
'weak'?: (boolean);
3129
'uninterpretedOption'?: (_google_protobuf_UninterpretedOption)[];
3230
'.validate.rules'?: (_validate_FieldRules);
33-
'.udpa.annotations.security'?: (_udpa_annotations_FieldSecurityAnnotation);
34-
'.udpa.annotations.sensitive'?: (boolean);
35-
'.udpa.annotations.field_migrate'?: (_udpa_annotations_FieldMigrateAnnotation);
36-
'.envoy.annotations.disallowed_by_default'?: (boolean);
3731
}
3832

3933
export interface FieldOptions__Output {
@@ -45,8 +39,4 @@ export interface FieldOptions__Output {
4539
'weak': (boolean);
4640
'uninterpretedOption': (_google_protobuf_UninterpretedOption__Output)[];
4741
'.validate.rules'?: (_validate_FieldRules__Output);
48-
'.udpa.annotations.security'?: (_udpa_annotations_FieldSecurityAnnotation__Output);
49-
'.udpa.annotations.sensitive': (boolean);
50-
'.udpa.annotations.field_migrate'?: (_udpa_annotations_FieldMigrateAnnotation__Output);
51-
'.envoy.annotations.disallowed_by_default': (boolean);
5242
}

packages/grpc-js-xds/src/generated/google/protobuf/FileOptions.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Original file: null
22

33
import type { UninterpretedOption as _google_protobuf_UninterpretedOption, UninterpretedOption__Output as _google_protobuf_UninterpretedOption__Output } from '../../google/protobuf/UninterpretedOption';
4-
import type { FileMigrateAnnotation as _udpa_annotations_FileMigrateAnnotation, FileMigrateAnnotation__Output as _udpa_annotations_FileMigrateAnnotation__Output } from '../../udpa/annotations/FileMigrateAnnotation';
5-
import type { StatusAnnotation as _udpa_annotations_StatusAnnotation, StatusAnnotation__Output as _udpa_annotations_StatusAnnotation__Output } from '../../udpa/annotations/StatusAnnotation';
64

75
// Original file: null
86

@@ -28,8 +26,6 @@ export interface FileOptions {
2826
'objcClassPrefix'?: (string);
2927
'csharpNamespace'?: (string);
3028
'uninterpretedOption'?: (_google_protobuf_UninterpretedOption)[];
31-
'.udpa.annotations.file_migrate'?: (_udpa_annotations_FileMigrateAnnotation);
32-
'.udpa.annotations.file_status'?: (_udpa_annotations_StatusAnnotation);
3329
}
3430

3531
export interface FileOptions__Output {
@@ -48,6 +44,4 @@ export interface FileOptions__Output {
4844
'objcClassPrefix': (string);
4945
'csharpNamespace': (string);
5046
'uninterpretedOption': (_google_protobuf_UninterpretedOption__Output)[];
51-
'.udpa.annotations.file_migrate'?: (_udpa_annotations_FileMigrateAnnotation__Output);
52-
'.udpa.annotations.file_status'?: (_udpa_annotations_StatusAnnotation__Output);
5347
}
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Original file: null
22

33
import type { UninterpretedOption as _google_protobuf_UninterpretedOption, UninterpretedOption__Output as _google_protobuf_UninterpretedOption__Output } from '../../google/protobuf/UninterpretedOption';
4-
import type { VersioningAnnotation as _udpa_annotations_VersioningAnnotation, VersioningAnnotation__Output as _udpa_annotations_VersioningAnnotation__Output } from '../../udpa/annotations/VersioningAnnotation';
5-
import type { MigrateAnnotation as _udpa_annotations_MigrateAnnotation, MigrateAnnotation__Output as _udpa_annotations_MigrateAnnotation__Output } from '../../udpa/annotations/MigrateAnnotation';
64

75
export interface MessageOptions {
86
'messageSetWireFormat'?: (boolean);
@@ -11,8 +9,6 @@ export interface MessageOptions {
119
'mapEntry'?: (boolean);
1210
'uninterpretedOption'?: (_google_protobuf_UninterpretedOption)[];
1311
'.validate.disabled'?: (boolean);
14-
'.udpa.annotations.versioning'?: (_udpa_annotations_VersioningAnnotation);
15-
'.udpa.annotations.message_migrate'?: (_udpa_annotations_MigrateAnnotation);
1612
}
1713

1814
export interface MessageOptions__Output {
@@ -22,6 +18,4 @@ export interface MessageOptions__Output {
2218
'mapEntry': (boolean);
2319
'uninterpretedOption': (_google_protobuf_UninterpretedOption__Output)[];
2420
'.validate.disabled': (boolean);
25-
'.udpa.annotations.versioning'?: (_udpa_annotations_VersioningAnnotation__Output);
26-
'.udpa.annotations.message_migrate'?: (_udpa_annotations_MigrateAnnotation__Output);
2721
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import type * as grpc from '@grpc/grpc-js';
2+
import type { ServiceDefinition, EnumTypeDefinition, MessageTypeDefinition } from '@grpc/proto-loader';
3+
4+
5+
type SubtypeConstructor<Constructor extends new (...args: any) => any, Subtype> = {
6+
new(...args: ConstructorParameters<Constructor>): Subtype;
7+
};
8+
9+
export interface ProtoGrpcType {
10+
google: {
11+
protobuf: {
12+
DescriptorProto: MessageTypeDefinition
13+
Duration: MessageTypeDefinition
14+
EnumDescriptorProto: MessageTypeDefinition
15+
EnumOptions: MessageTypeDefinition
16+
EnumValueDescriptorProto: MessageTypeDefinition
17+
EnumValueOptions: MessageTypeDefinition
18+
FieldDescriptorProto: MessageTypeDefinition
19+
FieldOptions: MessageTypeDefinition
20+
FileDescriptorProto: MessageTypeDefinition
21+
FileDescriptorSet: MessageTypeDefinition
22+
FileOptions: MessageTypeDefinition
23+
GeneratedCodeInfo: MessageTypeDefinition
24+
ListValue: MessageTypeDefinition
25+
MessageOptions: MessageTypeDefinition
26+
MethodDescriptorProto: MessageTypeDefinition
27+
MethodOptions: MessageTypeDefinition
28+
NullValue: EnumTypeDefinition
29+
OneofDescriptorProto: MessageTypeDefinition
30+
OneofOptions: MessageTypeDefinition
31+
ServiceDescriptorProto: MessageTypeDefinition
32+
ServiceOptions: MessageTypeDefinition
33+
SourceCodeInfo: MessageTypeDefinition
34+
Struct: MessageTypeDefinition
35+
Timestamp: MessageTypeDefinition
36+
UninterpretedOption: MessageTypeDefinition
37+
Value: MessageTypeDefinition
38+
}
39+
}
40+
udpa: {
41+
type: {
42+
v1: {
43+
TypedStruct: MessageTypeDefinition
44+
}
45+
}
46+
}
47+
validate: {
48+
AnyRules: MessageTypeDefinition
49+
BoolRules: MessageTypeDefinition
50+
BytesRules: MessageTypeDefinition
51+
DoubleRules: MessageTypeDefinition
52+
DurationRules: MessageTypeDefinition
53+
EnumRules: MessageTypeDefinition
54+
FieldRules: MessageTypeDefinition
55+
Fixed32Rules: MessageTypeDefinition
56+
Fixed64Rules: MessageTypeDefinition
57+
FloatRules: MessageTypeDefinition
58+
Int32Rules: MessageTypeDefinition
59+
Int64Rules: MessageTypeDefinition
60+
KnownRegex: EnumTypeDefinition
61+
MapRules: MessageTypeDefinition
62+
MessageRules: MessageTypeDefinition
63+
RepeatedRules: MessageTypeDefinition
64+
SFixed32Rules: MessageTypeDefinition
65+
SFixed64Rules: MessageTypeDefinition
66+
SInt32Rules: MessageTypeDefinition
67+
SInt64Rules: MessageTypeDefinition
68+
StringRules: MessageTypeDefinition
69+
TimestampRules: MessageTypeDefinition
70+
UInt32Rules: MessageTypeDefinition
71+
UInt64Rules: MessageTypeDefinition
72+
}
73+
}
74+
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// Original file: deps/udpa/udpa/type/v1/typed_struct.proto
2+
3+
import type { Struct as _google_protobuf_Struct, Struct__Output as _google_protobuf_Struct__Output } from '../../../google/protobuf/Struct';
4+
5+
/**
6+
* A TypedStruct contains an arbitrary JSON serialized protocol buffer message with a URL that
7+
* describes the type of the serialized message. This is very similar to google.protobuf.Any,
8+
* instead of having protocol buffer binary, this employs google.protobuf.Struct as value.
9+
*
10+
* This message is intended to be embedded inside Any, so it shouldn't be directly referred
11+
* from other UDPA messages.
12+
*
13+
* When packing an opaque extension config, packing the expected type into Any is preferred
14+
* wherever possible for its efficiency. TypedStruct should be used only if a proto descriptor
15+
* is not available, for example if:
16+
* - A control plane sends opaque message that is originally from external source in human readable
17+
* format such as JSON or YAML.
18+
* - The control plane doesn't have the knowledge of the protocol buffer schema hence it cannot
19+
* serialize the message in protocol buffer binary format.
20+
* - The DPLB doesn't have have the knowledge of the protocol buffer schema its plugin or extension
21+
* uses. This has to be indicated in the DPLB capability negotiation.
22+
*
23+
* When a DPLB receives a TypedStruct in Any, it should:
24+
* - Check if the type_url of the TypedStruct matches the type the extension expects.
25+
* - Convert value to the type described in type_url and perform validation.
26+
* TODO(lizan): Figure out how TypeStruct should be used with DPLB extensions that doesn't link
27+
* protobuf descriptor with DPLB itself, (e.g. gRPC LB Plugin, Envoy WASM extensions).
28+
*/
29+
export interface TypedStruct {
30+
/**
31+
* A URL that uniquely identifies the type of the serialize protocol buffer message.
32+
* This has same semantics and format described in google.protobuf.Any:
33+
* https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto
34+
*/
35+
'type_url'?: (string);
36+
/**
37+
* A JSON representation of the above specified type.
38+
*/
39+
'value'?: (_google_protobuf_Struct);
40+
}
41+
42+
/**
43+
* A TypedStruct contains an arbitrary JSON serialized protocol buffer message with a URL that
44+
* describes the type of the serialized message. This is very similar to google.protobuf.Any,
45+
* instead of having protocol buffer binary, this employs google.protobuf.Struct as value.
46+
*
47+
* This message is intended to be embedded inside Any, so it shouldn't be directly referred
48+
* from other UDPA messages.
49+
*
50+
* When packing an opaque extension config, packing the expected type into Any is preferred
51+
* wherever possible for its efficiency. TypedStruct should be used only if a proto descriptor
52+
* is not available, for example if:
53+
* - A control plane sends opaque message that is originally from external source in human readable
54+
* format such as JSON or YAML.
55+
* - The control plane doesn't have the knowledge of the protocol buffer schema hence it cannot
56+
* serialize the message in protocol buffer binary format.
57+
* - The DPLB doesn't have have the knowledge of the protocol buffer schema its plugin or extension
58+
* uses. This has to be indicated in the DPLB capability negotiation.
59+
*
60+
* When a DPLB receives a TypedStruct in Any, it should:
61+
* - Check if the type_url of the TypedStruct matches the type the extension expects.
62+
* - Convert value to the type described in type_url and perform validation.
63+
* TODO(lizan): Figure out how TypeStruct should be used with DPLB extensions that doesn't link
64+
* protobuf descriptor with DPLB itself, (e.g. gRPC LB Plugin, Envoy WASM extensions).
65+
*/
66+
export interface TypedStruct__Output {
67+
/**
68+
* A URL that uniquely identifies the type of the serialize protocol buffer message.
69+
* This has same semantics and format described in google.protobuf.Any:
70+
* https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.proto
71+
*/
72+
'type_url': (string);
73+
/**
74+
* A JSON representation of the above specified type.
75+
*/
76+
'value'?: (_google_protobuf_Struct__Output);
77+
}

0 commit comments

Comments
 (0)