1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
// This file is @generated by prost-build.
/// This message specifies the filter protocol configurations which will be sent to the ext_proc
/// server in a :ref:`ProcessingRequest <envoy_v3_api_msg_service.ext_proc.v3.ProcessingRequest>`.
/// If the server does not support these protocol configurations, it may choose to close the gRPC
/// stream. If the server supports these protocol configurations, it should respond based on the
/// API specifications.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct ProtocolConfiguration {
///
/// Specifies the filter configuration
/// : ref:`request_body_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ProcessingMode.request_body_mode>`.
#[prost(
enumeration = "super::super::super::extensions::filters::http::ext_proc::v3::processing_mode::BodySendMode",
tag = "1"
)]
pub request_body_mode: i32,
///
/// Specifies the filter configuration
/// : ref:`response_body_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ProcessingMode.response_body_mode>`.
#[prost(
enumeration = "super::super::super::extensions::filters::http::ext_proc::v3::processing_mode::BodySendMode",
tag = "2"
)]
pub response_body_mode: i32,
///
/// Specifies the filter configuration
/// : ref:`send_body_without_waiting_for_header_response <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.send_body_without_waiting_for_header_response>`.
/// If the client is waiting for a header response from the server, setting to `true` means the
/// client will send the body to the server as it arrives. Setting to `false` means the client
/// will buffer the arrived data and not send it to the server immediately.
#[prost(bool, tag = "3")]
pub send_body_without_waiting_for_header_response: bool,
}
impl ::prost::Name for ProtocolConfiguration {
const NAME: &'static str = "ProtocolConfiguration";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.ProtocolConfiguration".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.ProtocolConfiguration".into()
}
}
/// This represents the different types of messages that the data plane can send
/// to an external processing server.
/// \[\#next-free-field: 12\]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProcessingRequest {
/// Dynamic metadata associated with the request.
#[prost(message, optional, tag = "8")]
pub metadata_context: ::core::option::Option<
super::super::super::config::core::v3::Metadata,
>,
///
/// The values of properties selected by the `request_attributes`
/// or `response_attributes` list in the configuration. Each entry
/// in the list is populated from the standard
/// : ref:`attributes <arch_overview_attributes>` supported in the data plane.
#[prost(map = "string, message", tag = "9")]
pub attributes: ::std::collections::HashMap<
::prost::alloc::string::String,
super::super::super::super::google::protobuf::Struct,
>,
///
/// Specifies whether the filter that sent this request is running in
/// : ref:`observability_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.observability_mode>`.
///
///
/// * A value of `false` indicates that the server must respond to this message by either
/// sending back a matching `ProcessingResponse` message, or by closing the stream.
/// * A value of `true` indicates that the server should not respond to this message, as any
/// responses will be ignored. However, it may still close the stream to indicate that no more
/// messages are needed.
///
/// Defaults to `false`.
#[prost(bool, tag = "10")]
pub observability_mode: bool,
/// Specify the filter protocol configurations to be sent to the server.
/// `protocol_config` is only encoded in the first `ProcessingRequest` message from the client to the server.
#[prost(message, optional, tag = "11")]
pub protocol_config: ::core::option::Option<ProtocolConfiguration>,
/// Each request message will include one of the following sub-messages. Which
/// ones are set for a particular HTTP request/response depend on the
/// processing mode.
#[prost(oneof = "processing_request::Request", tags = "2, 3, 4, 5, 6, 7")]
pub request: ::core::option::Option<processing_request::Request>,
}
/// Nested message and enum types in `ProcessingRequest`.
pub mod processing_request {
/// Each request message will include one of the following sub-messages. Which
/// ones are set for a particular HTTP request/response depend on the
/// processing mode.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Request {
/// Information about the HTTP request headers, as well as peer info and additional
/// properties. Unless `observability_mode` is `true`, the server must send back a
/// `HeaderResponse` message, an `ImmediateResponse` message, or close the stream.
#[prost(message, tag = "2")]
RequestHeaders(super::HttpHeaders),
/// Information about the HTTP response headers, as well as peer info and additional
/// properties. Unless `observability_mode` is `true`, the server must send back a
/// `HeaderResponse` message or close the stream.
#[prost(message, tag = "3")]
ResponseHeaders(super::HttpHeaders),
/// A chunk of the HTTP request body. Unless `observability_mode` is `true`, the server must
/// send back a `BodyResponse` message, an `ImmediateResponse` message, or close the stream.
#[prost(message, tag = "4")]
RequestBody(super::HttpBody),
/// A chunk of the HTTP response body. Unless `observability_mode` is `true`, the server must
/// send back a `BodyResponse` message or close the stream.
#[prost(message, tag = "5")]
ResponseBody(super::HttpBody),
/// The HTTP trailers for the request path. Unless `observability_mode` is `true`, the server
/// must send back a `TrailerResponse` message or close the stream.
///
/// This message is only sent if the trailers processing mode is set to `SEND` and
/// the original downstream request has trailers.
#[prost(message, tag = "6")]
RequestTrailers(super::HttpTrailers),
/// The HTTP trailers for the response path. Unless `observability_mode` is `true`, the server
/// must send back a `TrailerResponse` message or close the stream.
///
/// This message is only sent if the trailers processing mode is set to `SEND` and
/// the original upstream response has trailers.
#[prost(message, tag = "7")]
ResponseTrailers(super::HttpTrailers),
}
}
impl ::prost::Name for ProcessingRequest {
const NAME: &'static str = "ProcessingRequest";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.ProcessingRequest".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.ProcessingRequest".into()
}
}
/// This represents the different types of messages the server may send back to the data plane
/// when the `observability_mode` field in the received `ProcessingRequest` is set to `false`.
///
/// *
/// If the corresponding `BodySendMode` in the
/// : ref:`processing_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.processing_mode>`
/// is not set to `FULL_DUPLEX_STREAMED`, then for every received `ProcessingRequest`,
/// the server must send back exactly one `ProcessingResponse` message.
///
///
/// * If it is set to `FULL_DUPLEX_STREAMED`, the server must follow the API defined
/// for this mode to send the `ProcessingResponse` messages.
/// \[\#next-free-field: 13\]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ProcessingResponse {
/// Optional metadata that will be emitted as dynamic metadata to be consumed by
/// following filters. This metadata will be placed in the namespace(s) specified by the top-level
/// field name(s) of the struct.
#[prost(message, optional, tag = "8")]
pub dynamic_metadata: ::core::option::Option<
super::super::super::super::google::protobuf::Struct,
>,
/// Override how parts of the HTTP request and response are processed for the duration of this
/// particular request/response only. Servers may use this to intelligently control how requests
/// are processed based on the headers and other metadata that they see.
///
///
/// This field is only applicable when servers are responding to the header requests. If it is set
/// in the response to the body or trailer requests, it will be ignored by the data plane.
/// It is also ignored by the data plane when the ext_proc filter config
/// : ref:`allow_mode_override <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.allow_mode_override>`
/// is set to `false`, or
/// : ref:`send_body_without_waiting_for_header_response <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.send_body_without_waiting_for_header_response>`
/// is set to `true`.
#[prost(message, optional, tag = "9")]
pub mode_override: ::core::option::Option<
super::super::super::extensions::filters::http::ext_proc::v3::ProcessingMode,
>,
/// \[\#not-implemented-hide:\]
/// Used only in `FULL_DUPLEX_STREAMED` and `GRPC` body send modes.
/// Instructs the data plane to stop sending body data and to send a
/// half-close on the ext_proc stream. The ext_proc server should then echo
/// back all subsequent body contents as-is until it sees the client's
/// half-close, at which point the ext_proc server can terminate the stream
/// with an OK status. This provides a safe way for the ext_proc server
/// to indicate that it does not need to see the rest of the stream;
/// without this, the ext_proc server could not terminate the stream
/// early, because it would wind up dropping any body contents that the
/// client had already sent before it saw the ext_proc stream termination.
#[prost(bool, tag = "12")]
pub request_drain: bool,
///
/// When the ext_proc server receives a request message and needs more time to process it, it
/// sends back a `ProcessingResponse` message with a new timeout value. When the data plane
/// receives this response message, it ignores other fields in the response, stops the original
/// timer (which has the timeout value specified in
/// : ref:`message_timeout <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.message_timeout>`),
/// and starts a new timer with this `override_message_timeout` value while keeping the data
/// plane ext_proc filter state machine intact.
///
/// The value must be >= 1ms and \<=
/// : ref:`max_message_timeout <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.max_message_timeout>`.
/// Such a message can be sent at most once in a particular data plane ext_proc filter processing
/// state. To enable this API, `max_message_timeout` must be set to a value >= 1ms.
#[prost(message, optional, tag = "10")]
pub override_message_timeout: ::core::option::Option<
super::super::super::super::google::protobuf::Duration,
>,
/// The response type that is sent by the server.
#[prost(oneof = "processing_response::Response", tags = "1, 2, 3, 4, 5, 6, 7, 11")]
pub response: ::core::option::Option<processing_response::Response>,
}
/// Nested message and enum types in `ProcessingResponse`.
pub mod processing_response {
/// The response type that is sent by the server.
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
/// The server must send back this message in response to a message with the
/// `request_headers` field set.
#[prost(message, tag = "1")]
RequestHeaders(super::HeadersResponse),
/// The server must send back this message in response to a message with the
/// `response_headers` field set.
#[prost(message, tag = "2")]
ResponseHeaders(super::HeadersResponse),
/// The server must send back this message in response to a message with
/// the `request_body` field set.
#[prost(message, tag = "3")]
RequestBody(super::BodyResponse),
/// The server must send back this message in response to a message with
/// the `response_body` field set.
#[prost(message, tag = "4")]
ResponseBody(super::BodyResponse),
/// The server must send back this message in response to a message with
/// the `request_trailers` field set.
#[prost(message, tag = "5")]
RequestTrailers(super::TrailersResponse),
/// The server must send back this message in response to a message with
/// the `response_trailers` field set.
#[prost(message, tag = "6")]
ResponseTrailers(super::TrailersResponse),
/// If specified, attempt to create a locally generated response, send it
/// downstream, and stop processing additional filters and ignore any
/// additional messages received from the remote server for this request or
/// response. If a response has already started -- for example, if this
/// message is sent response to a `response_body` message -- then
/// this will either ship the reply directly to the downstream codec,
/// or reset the stream.
#[prost(message, tag = "7")]
ImmediateResponse(super::ImmediateResponse),
///
/// The server sends back this message to initiate or continue local response streaming.
/// The server must initiate local response streaming with the `headers_response` in response
/// to a `ProcessingRequest` with the `request_headers` only.
/// The server may follow up with multiple messages containing `body_response`. The server must
/// indicate end of stream by setting `end_of_stream` to `true` in the `headers_response`
/// or `body_response` message or by sending a `trailers_response` message.
/// The client may send a `request_body` or `request_trailers` to the server depending on
/// configuration.
/// The streaming local response can only be sent when the `request_header_mode` in the filter
/// : ref:`processing_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.processing_mode>`
/// is set to `SEND`. The ext_proc server should not send `StreamedImmediateResponse` if it
/// did not observe request headers, as it will result in a race with the upstream server
/// response and reset of the client request.
/// Presently only the `FULL_DUPLEX_STREAMED` or `NONE` body modes are supported.
#[prost(message, tag = "11")]
StreamedImmediateResponse(super::StreamedImmediateResponse),
}
}
impl ::prost::Name for ProcessingResponse {
const NAME: &'static str = "ProcessingResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.ProcessingResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.ProcessingResponse".into()
}
}
/// This message is sent to the external server when the HTTP request and response headers
/// are first received.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HttpHeaders {
///
/// The HTTP request headers. All header keys will be lower-cased, because HTTP header keys are
/// case-insensitive. The header value is encoded in the
/// : ref:`raw_value <envoy_v3_api_field_config.core.v3.HeaderValue.raw_value>` field.
#[prost(message, optional, tag = "1")]
pub headers: ::core::option::Option<
super::super::super::config::core::v3::HeaderMap,
>,
///
/// \[\#not-implemented-hide:\]
/// This field is deprecated and not implemented. Attributes will be sent in the top-level
/// : ref:`attributes <envoy_v3_api_field_service.ext_proc.v3.ProcessingRequest.attributes>` field.
#[prost(map = "string, message", tag = "2")]
pub attributes: ::std::collections::HashMap<
::prost::alloc::string::String,
super::super::super::super::google::protobuf::Struct,
>,
/// If `true`, then there is no message body associated with this request or response.
#[prost(bool, tag = "3")]
pub end_of_stream: bool,
}
impl ::prost::Name for HttpHeaders {
const NAME: &'static str = "HttpHeaders";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.HttpHeaders".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.HttpHeaders".into()
}
}
/// This message is sent to the external server when the HTTP request and response bodies are
/// received.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct HttpBody {
/// The contents of the body in the HTTP request/response. Note that in streaming mode multiple
/// `HttpBody` messages may be sent.
///
/// In `GRPC` body send mode, a separate `HttpBody` message will be sent for each message in
/// the gRPC stream.
#[prost(bytes = "vec", tag = "1")]
pub body: ::prost::alloc::vec::Vec<u8>,
/// If `true`, this will be the last `HttpBody` message that will be sent and no trailers
/// will be sent for the current request/response.
#[prost(bool, tag = "2")]
pub end_of_stream: bool,
/// This field is used in `GRPC` body send mode when `end_of_stream` is `true` and `body`
/// is empty. Those values would normally indicate an empty message on the stream with the
/// end-of-stream bit set. However, if the half-close happens after the last message on the stream
/// was already sent, then this field will be `true` to indicate an end-of-stream with *no*
/// message (as opposed to an empty message).
#[prost(bool, tag = "3")]
pub end_of_stream_without_message: bool,
/// This field is used in `GRPC` body send mode to indicate whether the message is compressed.
/// This will never be set to `true` by gRPC but may be set to `true` by a proxy like Envoy.
#[prost(bool, tag = "4")]
pub grpc_message_compressed: bool,
}
impl ::prost::Name for HttpBody {
const NAME: &'static str = "HttpBody";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.HttpBody".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.HttpBody".into()
}
}
/// This message is sent to the external server when the HTTP request and
/// response trailers are received.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HttpTrailers {
///
/// The header value is encoded in the
/// : ref:`raw_value <envoy_v3_api_field_config.core.v3.HeaderValue.raw_value>` field.
#[prost(message, optional, tag = "1")]
pub trailers: ::core::option::Option<
super::super::super::config::core::v3::HeaderMap,
>,
}
impl ::prost::Name for HttpTrailers {
const NAME: &'static str = "HttpTrailers";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.HttpTrailers".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.HttpTrailers".into()
}
}
/// This message is sent by the external server to the data plane after `HttpHeaders` was
/// sent to it.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HeadersResponse {
/// Details the modifications (if any) to be made by the data plane to the current
/// request/response.
#[prost(message, optional, tag = "1")]
pub response: ::core::option::Option<CommonResponse>,
}
impl ::prost::Name for HeadersResponse {
const NAME: &'static str = "HeadersResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.HeadersResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.HeadersResponse".into()
}
}
/// This message is sent by the external server to the data plane after `HttpBody` was
/// sent to it.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BodyResponse {
/// Details the modifications (if any) to be made by the data plane to the current
/// request/response.
#[prost(message, optional, tag = "1")]
pub response: ::core::option::Option<CommonResponse>,
}
impl ::prost::Name for BodyResponse {
const NAME: &'static str = "BodyResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.BodyResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.BodyResponse".into()
}
}
/// This message is sent by the external server to the data plane after `HttpTrailers` was
/// sent to it.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TrailersResponse {
/// Details the modifications (if any) to be made by the data plane to the current
/// request/response trailers.
#[prost(message, optional, tag = "1")]
pub header_mutation: ::core::option::Option<HeaderMutation>,
}
impl ::prost::Name for TrailersResponse {
const NAME: &'static str = "TrailersResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.TrailersResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.TrailersResponse".into()
}
}
/// This message is sent by the external server to the data plane after `HttpHeaders` to initiate
/// local response streaming. The server may follow up with multiple messages containing
/// `body_response`. The server must indicate end of stream by setting `end_of_stream` to
/// `true` in the `headers_response` or `body_response` message or by sending a
/// `trailers_response` message.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct StreamedImmediateResponse {
#[prost(oneof = "streamed_immediate_response::Response", tags = "1, 2, 3")]
pub response: ::core::option::Option<streamed_immediate_response::Response>,
}
/// Nested message and enum types in `StreamedImmediateResponse`.
pub mod streamed_immediate_response {
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum Response {
/// Response headers to be sent downstream. The `:status` header must be set.
#[prost(message, tag = "1")]
HeadersResponse(super::HttpHeaders),
/// Response body to be sent downstream.
#[prost(message, tag = "2")]
BodyResponse(super::StreamedBodyResponse),
/// Response trailers to be sent downstream.
#[prost(message, tag = "3")]
TrailersResponse(super::super::super::super::config::core::v3::HeaderMap),
}
}
impl ::prost::Name for StreamedImmediateResponse {
const NAME: &'static str = "StreamedImmediateResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.StreamedImmediateResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.StreamedImmediateResponse".into()
}
}
/// This message contains common fields between header and body responses.
/// \[\#next-free-field: 6\]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CommonResponse {
/// If set, provide additional direction on how the data plane should
/// handle the rest of the HTTP filter chain.
#[prost(enumeration = "common_response::ResponseStatus", tag = "1")]
pub status: i32,
/// Instructions on how to manipulate the headers. When responding to an
/// `HttpBody` request, header mutations will only take effect if the current processing mode
/// for the body is `BUFFERED`.
#[prost(message, optional, tag = "2")]
pub header_mutation: ::core::option::Option<HeaderMutation>,
///
/// Replace the body of the last message sent to the remote server on this stream. If responding
/// to an `HttpBody` request, simply replace or clear the body chunk that was sent with that
/// request. Body mutations may take effect in response either to `header` or `body` messages.
/// When it is in response to `header` messages, it only takes effect if the
/// : ref:`status <envoy_v3_api_field_service.ext_proc.v3.CommonResponse.status>`
/// is set to `CONTINUE_AND_REPLACE`.
#[prost(message, optional, tag = "3")]
pub body_mutation: ::core::option::Option<BodyMutation>,
///
/// \[\#not-implemented-hide:\]
/// Add new trailers to the message. This may be used when responding to either an
/// `HttpHeaders` or `HttpBody` message, but only if this message is returned
/// along with the `CONTINUE_AND_REPLACE` status.
/// The header value is encoded in the
/// : ref:`raw_value <envoy_v3_api_field_config.core.v3.HeaderValue.raw_value>` field.
#[prost(message, optional, tag = "4")]
pub trailers: ::core::option::Option<
super::super::super::config::core::v3::HeaderMap,
>,
/// Clear the route cache for the current client request. This is necessary
/// if the remote server modified headers that are used to calculate the route.
/// This field is ignored in the response direction. This field is also ignored
/// if the data plane ext_proc filter is in the upstream filter chain.
#[prost(bool, tag = "5")]
pub clear_route_cache: bool,
}
/// Nested message and enum types in `CommonResponse`.
pub mod common_response {
/// The status of the response.
#[derive(
Clone,
Copy,
Debug,
PartialEq,
Eq,
Hash,
PartialOrd,
Ord,
::prost::Enumeration
)]
#[repr(i32)]
pub enum ResponseStatus {
/// Apply the mutation instructions in this message to the
/// request or response, and then continue processing the filter
/// stream as normal. This is the default.
Continue = 0,
/// Apply the specified header mutation, replace the body with the body
/// specified in the body mutation (if present), and do not send any
/// further messages for this request or response even if the processing
/// mode is configured to do so.
///
/// When used in response to a `request_headers` or `response_headers` message,
/// this status makes it possible to either completely replace the body
/// while discarding the original body, or to add a body to a message that
/// formerly did not have one.
///
/// In other words, this response makes it possible to turn an HTTP GET
/// into a POST, PUT, or PATCH.
///
/// Not supported if the body send mode is `GRPC`.
ContinueAndReplace = 1,
}
impl ResponseStatus {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Self::Continue => "CONTINUE",
Self::ContinueAndReplace => "CONTINUE_AND_REPLACE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"CONTINUE" => Some(Self::Continue),
"CONTINUE_AND_REPLACE" => Some(Self::ContinueAndReplace),
_ => None,
}
}
}
}
impl ::prost::Name for CommonResponse {
const NAME: &'static str = "CommonResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.CommonResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.CommonResponse".into()
}
}
/// This message causes the filter to attempt to create a locally generated response, send it
/// downstream, stop processing additional filters, and ignore any additional messages received
/// from the remote server for this request or response. If a response has already started, then
/// this will either ship the reply directly to the downstream codec, or reset the stream.
/// \[\#next-free-field: 6\]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ImmediateResponse {
/// The response code to return.
#[prost(message, optional, tag = "1")]
pub status: ::core::option::Option<super::super::super::r#type::v3::HttpStatus>,
/// Apply changes to the default headers, which will include `content-type`.
#[prost(message, optional, tag = "2")]
pub headers: ::core::option::Option<HeaderMutation>,
/// The message body to return with the response which is sent using the
/// `text/plain` content type, or encoded in the `grpc-message` header.
#[prost(bytes = "vec", tag = "3")]
pub body: ::prost::alloc::vec::Vec<u8>,
/// If set, then include a gRPC status trailer.
#[prost(message, optional, tag = "4")]
pub grpc_status: ::core::option::Option<GrpcStatus>,
/// A string detailing why this local reply was sent, which may be included
/// in log and debug output (e.g., this populates the `%RESPONSE_CODE_DETAILS%`
/// command operator field for use in access logging).
#[prost(string, tag = "5")]
pub details: ::prost::alloc::string::String,
}
impl ::prost::Name for ImmediateResponse {
const NAME: &'static str = "ImmediateResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.ImmediateResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.ImmediateResponse".into()
}
}
/// This message specifies a gRPC status for an `ImmediateResponse` message.
#[derive(Clone, Copy, PartialEq, Eq, Hash, ::prost::Message)]
pub struct GrpcStatus {
/// The actual gRPC status.
#[prost(uint32, tag = "1")]
pub status: u32,
}
impl ::prost::Name for GrpcStatus {
const NAME: &'static str = "GrpcStatus";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.GrpcStatus".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.GrpcStatus".into()
}
}
/// Change HTTP headers or trailers by appending, replacing, or removing
/// headers.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct HeaderMutation {
///
/// Add or replace HTTP headers. Attempts to set the value of
/// any `x-envoy` header, and attempts to set the `:method`,
/// `:authority`, `:scheme`, or `host` headers will be ignored.
/// The header value is encoded in the
/// : ref:`raw_value <envoy_v3_api_field_config.core.v3.HeaderValue.raw_value>` field.
#[prost(message, repeated, tag = "1")]
pub set_headers: ::prost::alloc::vec::Vec<
super::super::super::config::core::v3::HeaderValueOption,
>,
/// Remove these HTTP headers. Attempts to remove system headers --
/// any header starting with `:`, plus `host` -- will be ignored.
#[prost(string, repeated, tag = "2")]
pub remove_headers: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
impl ::prost::Name for HeaderMutation {
const NAME: &'static str = "HeaderMutation";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.HeaderMutation".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.HeaderMutation".into()
}
}
/// The body response message corresponding to `FULL_DUPLEX_STREAMED` or `GRPC` body modes.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct StreamedBodyResponse {
/// In `FULL_DUPLEX_STREAMED` body send mode, contains the body response chunk that will be
/// passed to the upstream/downstream by the data plane. In `GRPC` body send mode, contains
/// a serialized gRPC message to be passed to the upstream/downstream by the data plane.
#[prost(bytes = "vec", tag = "1")]
pub body: ::prost::alloc::vec::Vec<u8>,
///
/// The server sets this flag to `true` if it has received a body request with
/// : ref:`end_of_stream <envoy_v3_api_field_service.ext_proc.v3.HttpBody.end_of_stream>` set to
/// `true`, and this is the last chunk of body responses.
///
///
/// Note that in `GRPC` body send mode, this allows the ext_proc server to tell the data plane
/// to send a half close after a client message, which will result in discarding any other
/// messages sent by the client application.
#[prost(bool, tag = "2")]
pub end_of_stream: bool,
/// This field is used in `GRPC` body send mode when `end_of_stream` is `true` and `body`
/// is empty. Those values would normally indicate an empty message on the stream with the
/// end-of-stream bit set. However, if the half-close happens after the last message on the stream
/// was already sent, then this field will be `true` to indicate an end-of-stream with *no*
/// message (as opposed to an empty message).
#[prost(bool, tag = "3")]
pub end_of_stream_without_message: bool,
/// This field is used in `GRPC` body send mode to indicate whether the message is compressed.
/// This will never be set to `true` by gRPC but may be set to `true` by a proxy like Envoy.
#[prost(bool, tag = "4")]
pub grpc_message_compressed: bool,
}
impl ::prost::Name for StreamedBodyResponse {
const NAME: &'static str = "StreamedBodyResponse";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.StreamedBodyResponse".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.StreamedBodyResponse".into()
}
}
/// This message specifies the body mutation the server sends to the data plane.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct BodyMutation {
/// The type of mutation for the body.
#[prost(oneof = "body_mutation::Mutation", tags = "1, 2, 3")]
pub mutation: ::core::option::Option<body_mutation::Mutation>,
}
/// Nested message and enum types in `BodyMutation`.
pub mod body_mutation {
/// The type of mutation for the body.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Oneof)]
pub enum Mutation {
///
/// The entire body to replace.
/// Should only be used when the corresponding `BodySendMode` in the
/// : ref:`processing_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.processing_mode>`
/// is not set to `FULL_DUPLEX_STREAMED` or `GRPC`.
#[prost(bytes, tag = "1")]
Body(::prost::alloc::vec::Vec<u8>),
///
/// Clear the corresponding body chunk. Should only be used when the corresponding
/// `BodySendMode` in the
/// : ref:`processing_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.processing_mode>`
/// is not set to `FULL_DUPLEX_STREAMED` or `GRPC`.
#[prost(bool, tag = "2")]
ClearBody(bool),
///
/// Must be used when the corresponding `BodySendMode` in the
/// : ref:`processing_mode <envoy_v3_api_field_extensions.filters.http.ext_proc.v3.ExternalProcessor.processing_mode>`
/// is set to `FULL_DUPLEX_STREAMED` or `GRPC`.
#[prost(message, tag = "3")]
StreamedResponse(super::StreamedBodyResponse),
}
}
impl ::prost::Name for BodyMutation {
const NAME: &'static str = "BodyMutation";
const PACKAGE: &'static str = "envoy.service.ext_proc.v3";
fn full_name() -> ::prost::alloc::string::String {
"envoy.service.ext_proc.v3.BodyMutation".into()
}
fn type_url() -> ::prost::alloc::string::String {
"type.googleapis.com/envoy.service.ext_proc.v3.BodyMutation".into()
}
}
/// Generated client implementations.
pub mod external_processor_client {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
use tonic::codegen::http::Uri;
/// A service that can access and modify HTTP requests and responses as part of a filter chain.
/// The overall external processing protocol works like this:
///
/// 1. The data plane sends to the service information about the HTTP request.
/// 1. The service sends back a `ProcessingResponse` message that directs the data plane to either
/// stop processing, continue without it, or send it the next chunk of the message body.
/// 1. If so requested, the data plane sends the server the message body in chunks, or the entire
/// body at once. In either case, the server may send back a `ProcessingResponse` for each
/// message it receives, or wait for a certain amount of body chunks to be received before
/// streaming back the `ProcessingResponse` messages.
/// 1. If so requested, the data plane sends the server the HTTP trailers, and the server sends back
/// a `ProcessingResponse`.
/// 1. At this point, request processing is done, and we pick up again at step 1 when the data plane
/// receives a response from the upstream server.
/// 1. At any point above, if the server closes the gRPC stream cleanly, then the data plane
/// proceeds without consulting the server.
/// 1. At any point above, if the server closes the gRPC stream with an error, then the data plane
/// returns a `500` error to the client, unless the filter was configured to ignore errors.
///
/// In other words, the process is a request/response conversation, but using a gRPC stream to make
/// it easier for the server to maintain state.
#[derive(Debug, Clone)]
pub struct ExternalProcessorClient<T> {
inner: tonic::client::Grpc<T>,
}
impl ExternalProcessorClient<tonic::transport::Channel> {
/// Attempt to create a new client by connecting to a given endpoint.
pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
where
D: TryInto<tonic::transport::Endpoint>,
D::Error: Into<StdError>,
{
let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
Ok(Self::new(conn))
}
}
impl<T> ExternalProcessorClient<T>
where
T: tonic::client::GrpcService<tonic::body::Body>,
T::Error: Into<StdError>,
T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
<T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
{
pub fn new(inner: T) -> Self {
let inner = tonic::client::Grpc::new(inner);
Self { inner }
}
pub fn with_origin(inner: T, origin: Uri) -> Self {
let inner = tonic::client::Grpc::with_origin(inner, origin);
Self { inner }
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> ExternalProcessorClient<InterceptedService<T, F>>
where
F: tonic::service::Interceptor,
T::ResponseBody: Default,
T: tonic::codegen::Service<
http::Request<tonic::body::Body>,
Response = http::Response<
<T as tonic::client::GrpcService<tonic::body::Body>>::ResponseBody,
>,
>,
<T as tonic::codegen::Service<
http::Request<tonic::body::Body>,
>>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
{
ExternalProcessorClient::new(InterceptedService::new(inner, interceptor))
}
/// Compress requests with the given encoding.
///
/// This requires the server to support it otherwise it might respond with an
/// error.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.send_compressed(encoding);
self
}
/// Enable decompressing responses.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.inner = self.inner.accept_compressed(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_decoding_message_size(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.inner = self.inner.max_encoding_message_size(limit);
self
}
/// This begins the bidirectional stream that the data plane will use to
/// give the server control over what the filter does. The actual
/// protocol is described by the `ProcessingRequest` and `ProcessingResponse`
/// messages below.
pub async fn process(
&mut self,
request: impl tonic::IntoStreamingRequest<Message = super::ProcessingRequest>,
) -> std::result::Result<
tonic::Response<tonic::codec::Streaming<super::ProcessingResponse>>,
tonic::Status,
> {
self.inner
.ready()
.await
.map_err(|e| {
tonic::Status::unknown(
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic_prost::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static(
"/envoy.service.ext_proc.v3.ExternalProcessor/Process",
);
let mut req = request.into_streaming_request();
req.extensions_mut()
.insert(
GrpcMethod::new(
"envoy.service.ext_proc.v3.ExternalProcessor",
"Process",
),
);
self.inner.streaming(req, path, codec).await
}
}
}
/// Generated server implementations.
pub mod external_processor_server {
#![allow(
unused_variables,
dead_code,
missing_docs,
clippy::wildcard_imports,
clippy::let_unit_value,
)]
use tonic::codegen::*;
/// Generated trait containing gRPC methods that should be implemented for use with ExternalProcessorServer.
#[async_trait]
pub trait ExternalProcessor: std::marker::Send + std::marker::Sync + 'static {
/// Server streaming response type for the Process method.
type ProcessStream: tonic::codegen::tokio_stream::Stream<
Item = std::result::Result<super::ProcessingResponse, tonic::Status>,
>
+ std::marker::Send
+ 'static;
/// This begins the bidirectional stream that the data plane will use to
/// give the server control over what the filter does. The actual
/// protocol is described by the `ProcessingRequest` and `ProcessingResponse`
/// messages below.
async fn process(
&self,
request: tonic::Request<tonic::Streaming<super::ProcessingRequest>>,
) -> std::result::Result<tonic::Response<Self::ProcessStream>, tonic::Status>;
}
/// A service that can access and modify HTTP requests and responses as part of a filter chain.
/// The overall external processing protocol works like this:
///
/// 1. The data plane sends to the service information about the HTTP request.
/// 1. The service sends back a `ProcessingResponse` message that directs the data plane to either
/// stop processing, continue without it, or send it the next chunk of the message body.
/// 1. If so requested, the data plane sends the server the message body in chunks, or the entire
/// body at once. In either case, the server may send back a `ProcessingResponse` for each
/// message it receives, or wait for a certain amount of body chunks to be received before
/// streaming back the `ProcessingResponse` messages.
/// 1. If so requested, the data plane sends the server the HTTP trailers, and the server sends back
/// a `ProcessingResponse`.
/// 1. At this point, request processing is done, and we pick up again at step 1 when the data plane
/// receives a response from the upstream server.
/// 1. At any point above, if the server closes the gRPC stream cleanly, then the data plane
/// proceeds without consulting the server.
/// 1. At any point above, if the server closes the gRPC stream with an error, then the data plane
/// returns a `500` error to the client, unless the filter was configured to ignore errors.
///
/// In other words, the process is a request/response conversation, but using a gRPC stream to make
/// it easier for the server to maintain state.
#[derive(Debug)]
pub struct ExternalProcessorServer<T> {
inner: Arc<T>,
accept_compression_encodings: EnabledCompressionEncodings,
send_compression_encodings: EnabledCompressionEncodings,
max_decoding_message_size: Option<usize>,
max_encoding_message_size: Option<usize>,
}
impl<T> ExternalProcessorServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
max_decoding_message_size: None,
max_encoding_message_size: None,
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
/// Enable decompressing requests with the given encoding.
#[must_use]
pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.accept_compression_encodings.enable(encoding);
self
}
/// Compress responses with the given encoding, if the client supports it.
#[must_use]
pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
self.send_compression_encodings.enable(encoding);
self
}
/// Limits the maximum size of a decoded message.
///
/// Default: `4MB`
#[must_use]
pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
self.max_decoding_message_size = Some(limit);
self
}
/// Limits the maximum size of an encoded message.
///
/// Default: `usize::MAX`
#[must_use]
pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
self.max_encoding_message_size = Some(limit);
self
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for ExternalProcessorServer<T>
where
T: ExternalProcessor,
B: Body + std::marker::Send + 'static,
B::Error: Into<StdError> + std::marker::Send + 'static,
{
type Response = http::Response<tonic::body::Body>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<std::result::Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
match req.uri().path() {
"/envoy.service.ext_proc.v3.ExternalProcessor/Process" => {
#[allow(non_camel_case_types)]
struct ProcessSvc<T: ExternalProcessor>(pub Arc<T>);
impl<
T: ExternalProcessor,
> tonic::server::StreamingService<super::ProcessingRequest>
for ProcessSvc<T> {
type Response = super::ProcessingResponse;
type ResponseStream = T::ProcessStream;
type Future = BoxFuture<
tonic::Response<Self::ResponseStream>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<
tonic::Streaming<super::ProcessingRequest>,
>,
) -> Self::Future {
let inner = Arc::clone(&self.0);
let fut = async move {
<T as ExternalProcessor>::process(&inner, request).await
};
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let max_decoding_message_size = self.max_decoding_message_size;
let max_encoding_message_size = self.max_encoding_message_size;
let inner = self.inner.clone();
let fut = async move {
let method = ProcessSvc(inner);
let codec = tonic_prost::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
)
.apply_max_message_size_config(
max_decoding_message_size,
max_encoding_message_size,
);
let res = grpc.streaming(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
let mut response = http::Response::new(
tonic::body::Body::default(),
);
let headers = response.headers_mut();
headers
.insert(
tonic::Status::GRPC_STATUS,
(tonic::Code::Unimplemented as i32).into(),
);
headers
.insert(
http::header::CONTENT_TYPE,
tonic::metadata::GRPC_CONTENT_TYPE,
);
Ok(response)
})
}
}
}
}
impl<T> Clone for ExternalProcessorServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
max_decoding_message_size: self.max_decoding_message_size,
max_encoding_message_size: self.max_encoding_message_size,
}
}
}
/// Generated gRPC service name
pub const SERVICE_NAME: &str = "envoy.service.ext_proc.v3.ExternalProcessor";
impl<T> tonic::server::NamedService for ExternalProcessorServer<T> {
const NAME: &'static str = SERVICE_NAME;
}
}