-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compression: create a decompressor extensibility point and move gzip …
…decompressor (#10744) creates decompressors as an extension point and moves the zlib based gzip decompressor. Signed-off-by: Jose Nino <jnino@lyft.com>
- Loading branch information
Showing
36 changed files
with
405 additions
and
57 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"], | ||
) |
30 changes: 30 additions & 0 deletions
30
api/envoy/extensions/compression/gzip/decompressor/v3/gzip.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.extensions.compression.gzip.decompressor.v3; | ||
|
||
import "google/protobuf/wrappers.proto"; | ||
|
||
import "udpa/annotations/migrate.proto"; | ||
import "udpa/annotations/status.proto"; | ||
import "udpa/annotations/versioning.proto"; | ||
import "validate/validate.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.extensions.compression.gzip.decompressor.v3"; | ||
option java_outer_classname = "GzipProto"; | ||
option java_multiple_files = true; | ||
option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
||
// [#protodoc-title: Gzip Decompressor] | ||
// [#extension: envoy.compression.gzip.decompressor] | ||
|
||
message Gzip { | ||
// Value from 9 to 15 that represents the base two logarithmic of the decompressor's window size. | ||
// The decompression window size needs to be equal or larger than the compression window size. | ||
// The default is 15 per zlib's manual. For more details about this parameter, please refer to | ||
// zlib manual > inflateInit2. | ||
google.protobuf.UInt32Value window_bits = 1 [(validate.rules).uint32 = {lte: 15 gte: 9}]; | ||
|
||
// Value for zlib's decompressor output buffer. If not set, defaults to 4096. | ||
// See https://www.zlib.net/manual.html for more details. | ||
google.protobuf.UInt32Value chunk_size = 2 [(validate.rules).uint32 = {lte: 65536 gte: 4096}]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
generated_api_shadow/envoy/extensions/compression/gzip/compressor/v3/gzip.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
generated_api_shadow/envoy/extensions/compression/gzip/decompressor/v3/BUILD
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
generated_api_shadow/envoy/extensions/compression/gzip/decompressor/v3/gzip.proto
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "decompressor_config_interface", | ||
hdrs = ["config.h"], | ||
deps = [ | ||
":decompressor_factory_interface", | ||
"//include/envoy/config:typed_config_interface", | ||
"//include/envoy/server:filter_config_interface", | ||
], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "decompressor_factory_interface", | ||
hdrs = ["factory.h"], | ||
deps = [ | ||
":decompressor_interface", | ||
], | ||
) | ||
|
||
envoy_cc_library( | ||
name = "decompressor_interface", | ||
hdrs = ["decompressor.h"], | ||
deps = [ | ||
"//include/envoy/buffer:buffer_interface", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "envoy/compression/decompressor/factory.h" | ||
#include "envoy/config/typed_config.h" | ||
#include "envoy/server/filter_config.h" | ||
|
||
namespace Envoy { | ||
namespace Compression { | ||
namespace Decompressor { | ||
|
||
class NamedDecompressorLibraryConfigFactory : public Config::TypedFactory { | ||
public: | ||
~NamedDecompressorLibraryConfigFactory() override = default; | ||
|
||
virtual DecompressorFactoryPtr | ||
createDecompressorFactoryFromProto(const Protobuf::Message& config, | ||
Server::Configuration::FactoryContext& context) PURE; | ||
|
||
std::string category() const override { return "envoy.compression.decompressor"; } | ||
}; | ||
|
||
} // namespace Decompressor | ||
} // namespace Compression | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "envoy/compression/decompressor/decompressor.h" | ||
|
||
namespace Envoy { | ||
namespace Compression { | ||
namespace Decompressor { | ||
|
||
class DecompressorFactory { | ||
public: | ||
virtual ~DecompressorFactory() = default; | ||
|
||
virtual DecompressorPtr createDecompressor() PURE; | ||
virtual const std::string& statsPrefix() const PURE; | ||
// TODO(junr03): this method assumes that decompressors are used on http messages. | ||
// A more generic method might be `hint()` which gives the user of the decompressor a hint about | ||
// the type of decompression that it can perform. | ||
virtual const std::string& contentEncoding() const PURE; | ||
}; | ||
|
||
using DecompressorFactoryPtr = std::unique_ptr<DecompressorFactory>; | ||
|
||
} // namespace Decompressor | ||
} // namespace Compression | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
source/extensions/compression/common/decompressor/factory_base.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include "envoy/compression/decompressor/config.h" | ||
|
||
namespace Envoy { | ||
namespace Extensions { | ||
namespace Compression { | ||
namespace Common { | ||
namespace Decompressor { | ||
|
||
template <class ConfigProto> | ||
class DecompressorLibraryFactoryBase | ||
: public Envoy::Compression::Decompressor::NamedDecompressorLibraryConfigFactory { | ||
public: | ||
Envoy::Compression::Decompressor::DecompressorFactoryPtr | ||
createDecompressorFactoryFromProto(const Protobuf::Message& proto_config, | ||
Server::Configuration::FactoryContext& context) override { | ||
return createDecompressorFactoryFromProtoTyped( | ||
MessageUtil::downcastAndValidate<const ConfigProto&>(proto_config, | ||
context.messageValidationVisitor())); | ||
} | ||
|
||
ProtobufTypes::MessagePtr createEmptyConfigProto() override { | ||
return std::make_unique<ConfigProto>(); | ||
} | ||
|
||
std::string name() const override { return name_; } | ||
|
||
protected: | ||
DecompressorLibraryFactoryBase(const std::string& name) : name_(name) {} | ||
|
||
private: | ||
virtual Envoy::Compression::Decompressor::DecompressorFactoryPtr | ||
createDecompressorFactoryFromProtoTyped(const ConfigProto&) PURE; | ||
|
||
const std::string name_; | ||
}; | ||
|
||
} // namespace Decompressor | ||
} // namespace Common | ||
} // namespace Compression | ||
} // namespace Extensions | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
licenses(["notice"]) # Apache 2 | ||
|
||
load( | ||
"//bazel:envoy_build_system.bzl", | ||
"envoy_cc_extension", | ||
"envoy_cc_library", | ||
"envoy_package", | ||
) | ||
|
||
envoy_package() | ||
|
||
envoy_cc_library( | ||
name = "zlib_decompressor_impl_lib", | ||
srcs = ["zlib_decompressor_impl.cc"], | ||
hdrs = ["zlib_decompressor_impl.h"], | ||
external_deps = ["zlib"], | ||
deps = [ | ||
"//include/envoy/compression/decompressor:decompressor_interface", | ||
"//source/common/buffer:buffer_lib", | ||
"//source/common/common:assert_lib", | ||
"//source/common/common:minimal_logger_lib", | ||
"//source/common/common:zlib_base_lib", | ||
], | ||
) | ||
|
||
envoy_cc_extension( | ||
name = "config", | ||
srcs = ["config.cc"], | ||
hdrs = ["config.h"], | ||
security_posture = "robust_to_untrusted_downstream", | ||
deps = [ | ||
":zlib_decompressor_impl_lib", | ||
"//source/common/http:headers_lib", | ||
"//source/extensions/compression/common/decompressor:decompressor_factory_base_lib", | ||
"@envoy_api//envoy/extensions/compression/gzip/decompressor/v3:pkg_cc_proto", | ||
], | ||
) |
Oops, something went wrong.