Skip to content

Commit

Permalink
PERL-1060: Make Compress::Snappy dependency optional
Browse files Browse the repository at this point in the history
  • Loading branch information
TBSliver committed Mar 13, 2019
1 parent b53e883 commit 1a77cf7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 0 additions & 1 deletion Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ my %WriteMakefileArgs = (
"BSON::Types" => 0,
"Carp" => 0,
"Compress::Zlib" => 0,
"Compress::Snappy" => 0,
"Digest::MD5" => 0,
"Encode" => 0,
"Exporter" => "5.57",
Expand Down
1 change: 1 addition & 0 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ remove = Authen::SASL
remove = BSON::XS
remove = Class::XSAccessor
remove = Compress::Zstd
remove = Compress::Snappy
remove = DateTime
remove = DateTime::Tiny
remove = Errno
Expand Down
7 changes: 6 additions & 1 deletion lib/MongoDB/_Protocol.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use MongoDB::Error;
use MongoDB::_Types qw/ to_IxHash /;

use Compress::Zlib ();
use Compress::Snappy ();

use constant {
OP_REPLY => 1, # Reply to a client request. responseTo is set
Expand Down Expand Up @@ -322,6 +321,11 @@ sub _assert_zstd {
unless eval { require Compress::Zstd };
}
sub _assert_snappy {
MongoDB::UsageError->throw(qq/Compress::Snappy must be installed to support snappy compression\n/)
unless eval { require Compress::Snappy };
}
# decompressors indexed by ID.
my @DECOMPRESSOR = (
# none
Expand All @@ -345,6 +349,7 @@ sub get_compressor {
};
}
elsif ($name eq 'snappy') {
_assert_snappy();
return {
id => 1,
callback => sub { Compress::Snappy::compress(shift) },
Expand Down

0 comments on commit 1a77cf7

Please sign in to comment.