compressor: expose generic compressor filter to users (#10553)

Currently the generic HTTP compressor filter isn't exposed to users
even though it's used internally by `envoy.filters.http.gzip` and can be
used by external filter extensions.

Expose the compressor's config API to users. For example the filter
can be configured as follows:

    ...
    filter_chains:
      filters:
      - name: envoy.http_connection_manager
        config:
          http_filters:
          - name: envoy.filters.http.compressor
            config:
              disable_on_etag_header: true
              content_length: 100
              content_type:
                - text/html
                - application/json
              compressor_library:
                name: envoy.filters.http.compressor.gzip
                config:
                  memory_level: 3
                  window_bits: 10
                  compression_level: best
                  compression_strategy: rle
    ...

Multiple compressor filters using different compressor libraries,
e.g. gzip and brotli, can be stacked in one filter chain.

Signed-off-by: Dmitry Rozhkov <dmitry.rozhkov@linux.intel.com>

Mirrored from https://github.com/envoyproxy/envoy @ 49efb9841a58ebdc43a666f55c445911c8e4181c
master-ci-test
data-plane-api(CircleCI) 5 years ago
parent 0a7d55ad12
commit 172f540c8b
  1. 1
      BUILD
  2. 9
      envoy/extensions/compression/gzip/compressor/v3/BUILD
  3. 79
      envoy/extensions/compression/gzip/compressor/v3/gzip.proto
  4. 13
      envoy/extensions/filters/http/compressor/v3/compressor.proto
  5. 1
      versioning/BUILD

@ -161,6 +161,7 @@ proto_library(
"//envoy/extensions/common/dynamic_forward_proxy/v3:pkg", "//envoy/extensions/common/dynamic_forward_proxy/v3:pkg",
"//envoy/extensions/common/ratelimit/v3:pkg", "//envoy/extensions/common/ratelimit/v3:pkg",
"//envoy/extensions/common/tap/v3:pkg", "//envoy/extensions/common/tap/v3:pkg",
"//envoy/extensions/compression/gzip/compressor/v3:pkg",
"//envoy/extensions/filters/common/fault/v3:pkg", "//envoy/extensions/filters/common/fault/v3:pkg",
"//envoy/extensions/filters/http/adaptive_concurrency/v3:pkg", "//envoy/extensions/filters/http/adaptive_concurrency/v3:pkg",
"//envoy/extensions/filters/http/aws_lambda/v3:pkg", "//envoy/extensions/filters/http/aws_lambda/v3:pkg",

@ -0,0 +1,9 @@
# DO NOT EDIT. This file is generated by tools/proto_sync.py.
load("@envoy_api//bazel:api_build_system.bzl", "api_proto_package")
licenses(["notice"]) # Apache 2
api_proto_package(
deps = ["@com_github_cncf_udpa//udpa/annotations:pkg"],
)

@ -0,0 +1,79 @@
syntax = "proto3";
package envoy.extensions.compression.gzip.compressor.v3;
import "google/protobuf/wrappers.proto";
import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto";
import "validate/validate.proto";
option java_package = "io.envoyproxy.envoy.extensions.compression.gzip.compressor.v3";
option java_outer_classname = "GzipProto";
option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE;
// [#protodoc-title: Gzip]
// [#extension: envoy.compression.gzip.compressor]
// [#next-free-field: 6]
message Gzip {
// All the values of this enumeration translate directly to zlib's compression strategies.
// For more information about each strategy, please refer to zlib manual.
enum CompressionStrategy {
DEFAULT_STRATEGY = 0;
FILTERED = 1;
HUFFMAN_ONLY = 2;
RLE = 3;
FIXED = 4;
}
enum CompressionLevel {
option allow_alias = true;
DEFAULT_COMPRESSION = 0;
BEST_SPEED = 1;
COMPRESSION_LEVEL_1 = 1;
COMPRESSION_LEVEL_2 = 2;
COMPRESSION_LEVEL_3 = 3;
COMPRESSION_LEVEL_4 = 4;
COMPRESSION_LEVEL_5 = 5;
COMPRESSION_LEVEL_6 = 6;
COMPRESSION_LEVEL_7 = 7;
COMPRESSION_LEVEL_8 = 8;
COMPRESSION_LEVEL_9 = 9;
BEST_COMPRESSION = 9;
}
// Value from 1 to 9 that controls the amount of internal memory used by zlib. Higher values
// use more memory, but are faster and produce better compression results. The default value is 5.
google.protobuf.UInt32Value memory_level = 1 [(validate.rules).uint32 = {lte: 9 gte: 1}];
// A value used for selecting the zlib compression level. This setting will affect speed and
// amount of compression applied to the content. "BEST_COMPRESSION" provides higher compression
// at the cost of higher latency and is equal to "COMPRESSION_LEVEL_9". "BEST_SPEED" provides
// lower compression with minimum impact on response time, the same as "COMPRESSION_LEVEL_1".
// "DEFAULT_COMPRESSION" provides an optimal result between speed and compression. According
// to zlib's manual this level gives the same result as "COMPRESSION_LEVEL_6".
// This field will be set to "DEFAULT_COMPRESSION" if not specified.
CompressionLevel compression_level = 2 [(validate.rules).enum = {defined_only: true}];
// A value used for selecting the zlib compression strategy which is directly related to the
// characteristics of the content. Most of the time "DEFAULT_STRATEGY" will be the best choice,
// which is also the default value for the parameter, though there are situations when
// changing this parameter might produce better results. For example, run-length encoding (RLE)
// is typically used when the content is known for having sequences which same data occurs many
// consecutive times. For more information about each strategy, please refer to zlib manual.
CompressionStrategy compression_strategy = 3 [(validate.rules).enum = {defined_only: true}];
// Value from 9 to 15 that represents the base two logarithmic of the compressor's window size.
// Larger window results in better compression at the expense of memory usage. The default is 12
// which will produce a 4096 bytes window. For more details about this parameter, please refer to
// zlib manual > deflateInit2.
google.protobuf.UInt32Value window_bits = 4 [(validate.rules).uint32 = {lte: 15 gte: 9}];
// Value for Zlib's next output buffer. If not set, defaults to 4096.
// See https://www.zlib.net/manual.html for more details. Also see
// https://github.com/envoyproxy/envoy/issues/8448 for context on this filter's performance.
google.protobuf.UInt32Value chunk_size = 5 [(validate.rules).uint32 = {lte: 65536 gte: 4096}];
}

@ -3,11 +3,14 @@ syntax = "proto3";
package envoy.extensions.filters.http.compressor.v3; package envoy.extensions.filters.http.compressor.v3;
import "envoy/config/core/v3/base.proto"; import "envoy/config/core/v3/base.proto";
import "envoy/config/core/v3/extension.proto";
import "google/protobuf/any.proto";
import "google/protobuf/wrappers.proto"; import "google/protobuf/wrappers.proto";
import "udpa/annotations/status.proto"; import "udpa/annotations/status.proto";
import "udpa/annotations/versioning.proto"; import "udpa/annotations/versioning.proto";
import "validate/validate.proto";
option java_package = "io.envoyproxy.envoy.extensions.filters.http.compressor.v3"; option java_package = "io.envoyproxy.envoy.extensions.filters.http.compressor.v3";
option java_outer_classname = "CompressorProto"; option java_outer_classname = "CompressorProto";
@ -15,8 +18,10 @@ option java_multiple_files = true;
option (udpa.annotations.file_status).package_version_status = ACTIVE; option (udpa.annotations.file_status).package_version_status = ACTIVE;
// [#protodoc-title: Compressor] // [#protodoc-title: Compressor]
// Compressor :ref:`configuration overview <config_http_filters_compressor>`.
// [#extension: envoy.filters.http.compressor]
// [#next-free-field: 6] // [#next-free-field: 7]
message Compressor { message Compressor {
option (udpa.annotations.versioning).previous_message_type = option (udpa.annotations.versioning).previous_message_type =
"envoy.config.filter.http.compressor.v2.Compressor"; "envoy.config.filter.http.compressor.v2.Compressor";
@ -46,4 +51,10 @@ message Compressor {
// Runtime flag that controls whether the filter is enabled or not. If set to false, the // Runtime flag that controls whether the filter is enabled or not. If set to false, the
// filter will operate as a pass-through filter. If not specified, defaults to enabled. // filter will operate as a pass-through filter. If not specified, defaults to enabled.
config.core.v3.RuntimeFeatureFlag runtime_enabled = 5; config.core.v3.RuntimeFeatureFlag runtime_enabled = 5;
// A compressor library to use for compression. Currently only
// :ref:`envoy.filters.http.compressor.gzip<envoy_api_msg_extensions.compression.gzip.compressor.v3.Gzip>`
// is included in Envoy.
// This field is ignored if used in the context of the gzip http-filter, but is mandatory otherwise.
config.core.v3.TypedExtensionConfig compressor_library = 6;
} }

@ -44,6 +44,7 @@ proto_library(
"//envoy/extensions/common/dynamic_forward_proxy/v3:pkg", "//envoy/extensions/common/dynamic_forward_proxy/v3:pkg",
"//envoy/extensions/common/ratelimit/v3:pkg", "//envoy/extensions/common/ratelimit/v3:pkg",
"//envoy/extensions/common/tap/v3:pkg", "//envoy/extensions/common/tap/v3:pkg",
"//envoy/extensions/compression/gzip/compressor/v3:pkg",
"//envoy/extensions/filters/common/fault/v3:pkg", "//envoy/extensions/filters/common/fault/v3:pkg",
"//envoy/extensions/filters/http/adaptive_concurrency/v3:pkg", "//envoy/extensions/filters/http/adaptive_concurrency/v3:pkg",
"//envoy/extensions/filters/http/aws_lambda/v3:pkg", "//envoy/extensions/filters/http/aws_lambda/v3:pkg",

Loading…
Cancel
Save