NAME
IPC::Manager::Serializer::JSON::Zstd - JSON serializer with zstd compression for IPC::Manager.
DESCRIPTION
Subclass of IPC::Manager::Serializer::JSON that compresses serialized payloads with Compress::Zstd before sending them and decompresses them on receipt. JSON encoding/decoding is delegated to the parent class; only the on-the-wire bytes are different.
When Compress::Zstd 0.20 or newer is installed JSON::Zstd is selected as the default serializer for IPC::Manager. If Compress::Zstd is missing or older, IPC::Manager falls back to IPC::Manager::Serializer::JSON.
The class methods serialize/deserialize use Compress::Zstd's default compression level (3) and no preset dictionary. To configure a custom compression level or use a preset dictionary, construct an instance via new(level => $level, dictionary => $path) and call the same methods on it. Instances are cached by IPC::Manager when specified through the arrayref form in ipcm_spawn / ipcm_connect, so each unique [$class, %args] spec produces a single shared serializer object that peer connections reuse.
SYNOPSIS
use IPC::Manager;
# Class form (default level, no dictionary)
my $ipcm = ipcm_spawn(serializer => 'JSON::Zstd');
# Arrayref form (custom level and/or dictionary)
my $ipcm = ipcm_spawn(
serializer => ['JSON::Zstd', level => 9, dictionary => '/path/to/dict'],
);
METHODS
- $bool = IPC::Manager::Serializer::JSON::Zstd->viable
-
Returns true when Compress::Zstd 0.20 or newer is loadable, false otherwise.
- $self = IPC::Manager::Serializer::JSON::Zstd->new(%args)
-
Construct a configured serializer instance. Recognized arguments:
- level => $integer
-
Zstd compression level. Defaults to
3(Compress::Zstd's library default). - dictionary => $path
-
Path to a zstd preset dictionary file. Both endpoints must have access to a dictionary at the same path with the same content. When set, the constructor loads the file once and reuses it for every
serialize/deserializecall.
- $bytes = $serializer->serialize($obj)
- $bytes = IPC::Manager::Serializer::JSON::Zstd->serialize($obj)
-
JSON-encode
$objand zstd-compress the result. The class form uses default level 3 and no dictionary; the instance form honours thelevelanddictionarythe instance was built with. - $obj = $serializer->deserialize($bytes)
- $obj = IPC::Manager::Serializer::JSON::Zstd->deserialize($bytes)
-
Zstd-decompress
$bytesand JSON-decode the result. The class form expects input produced without a dictionary; the instance form decodes with the instance's dictionary if one was configured.
SOURCE
The source code repository for IPC::Manager can be found at https://github.com/exodist/IPC-Manager.
MAINTAINERS
AUTHORS
COPYRIGHT
Copyright Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.