1
#include "source/extensions/compression/brotli/decompressor/config.h"
2

            
3
namespace Envoy {
4
namespace Extensions {
5
namespace Compression {
6
namespace Brotli {
7
namespace Decompressor {
8

            
9
namespace {
10

            
11
const uint32_t DefaultChunkSize = 4096;
12

            
13
} // namespace
14

            
15
BrotliDecompressorFactory::BrotliDecompressorFactory(
16
    const envoy::extensions::compression::brotli::decompressor::v3::Brotli& brotli,
17
    Stats::Scope& scope)
18
1
    : scope_(scope),
19
1
      chunk_size_(PROTOBUF_GET_WRAPPED_OR_DEFAULT(brotli, chunk_size, DefaultChunkSize)),
20
1
      disable_ring_buffer_reallocation_{brotli.disable_ring_buffer_reallocation()} {}
21

            
22
Envoy::Compression::Decompressor::DecompressorPtr
23
1
BrotliDecompressorFactory::createDecompressor(const std::string& stats_prefix) {
24
1
  return std::make_unique<BrotliDecompressorImpl>(scope_, stats_prefix, chunk_size_,
25
1
                                                  disable_ring_buffer_reallocation_);
26
1
}
27

            
28
Envoy::Compression::Decompressor::DecompressorFactoryPtr
29
BrotliDecompressorLibraryFactory::createDecompressorFactoryFromProtoTyped(
30
    const envoy::extensions::compression::brotli::decompressor::v3::Brotli& proto_config,
31
1
    Server::Configuration::FactoryContext& context) {
32
1
  return std::make_unique<BrotliDecompressorFactory>(proto_config, context.scope());
33
1
}
34

            
35
/**
36
 * Static registration for the brotli decompressor. @see NamedDecompressorLibraryConfigFactory.
37
 */
38
REGISTER_FACTORY(BrotliDecompressorLibraryFactory,
39
                 Envoy::Compression::Decompressor::NamedDecompressorLibraryConfigFactory);
40
} // namespace Decompressor
41
} // namespace Brotli
42
} // namespace Compression
43
} // namespace Extensions
44
} // namespace Envoy