omq-rfc-zstd 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +15 -0
- data/README.md +81 -0
- data/RFC.md +630 -0
- data/lib/omq/rfc/zstd/codec.rb +98 -0
- data/lib/omq/rfc/zstd/compression.rb +232 -0
- data/lib/omq/rfc/zstd/connection.rb +175 -0
- data/lib/omq/rfc/zstd/constants.rb +40 -0
- data/lib/omq/rfc/zstd/engine_ext.rb +49 -0
- data/lib/omq/rfc/zstd/options_ext.rb +43 -0
- data/lib/omq/rfc/zstd/socket_ext.rb +3 -0
- data/lib/omq/rfc/zstd/version.rb +9 -0
- data/lib/omq/rfc/zstd.rb +10 -0
- metadata +95 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d3cb484a523975a0cb8d80b5270f89e98f536169fbe11e1a7af3b36b9529ffc5
|
|
4
|
+
data.tar.gz: 11e6f5671d24f0e7585aa9ca2055cbaa6a1a79e6dcd36070360d3b3823cbec78
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ff90b8650aa506957fad84948dbe5f1d4731c5958d6ca28d135726fdd9a403a31d744f50bae0ed8acfacb38cae4d085ca6853d1b0b6e439452621e60a9ddfac2
|
|
7
|
+
data.tar.gz: 7537425c8a88ff2cdb55029f62c494eff1ab77bb858ff3ed493276af55428983c850378663ba2631ee9f1e6eb45d546c4eef5a953901a91270bf524de85ad91d
|
data/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Patrik Wenger
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# omq-rfc-zstd
|
|
2
|
+
|
|
3
|
+
[](https://rubygems.org/gems/omq-rfc-zstd)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
[](https://www.ruby-lang.org)
|
|
6
|
+
|
|
7
|
+
> **Status:** Draft. The wire format and API may change before the first tagged release.
|
|
8
|
+
|
|
9
|
+
Transparent, negotiated **Zstandard** compression for [OMQ](https://github.com/paddor/omq).
|
|
10
|
+
Sender and receiver advertise compression support via a ZMTP READY property
|
|
11
|
+
during the handshake. If both peers advertise it, message frame bodies are
|
|
12
|
+
compressed per-frame on the wire, optionally using a shared dictionary for
|
|
13
|
+
small messages.
|
|
14
|
+
|
|
15
|
+
See [RFC.md](RFC.md) for the full specification.
|
|
16
|
+
|
|
17
|
+
## Goals
|
|
18
|
+
|
|
19
|
+
- **Transparent**: existing OMQ code sees plaintext; compression happens under the socket.
|
|
20
|
+
- **Backwards compatible**: a peer that does not advertise compression is served plaintext. libzmq and other ZMTP 3.1 peers remain interoperable.
|
|
21
|
+
- **Small-message friendly**: an optional shared dictionary makes compression useful even for messages in the dozens-to-hundreds-of-bytes range. Without a dictionary, the sender skips compression for frames below 512 B.
|
|
22
|
+
- **Pay-per-frame**: the sender MAY skip compression on a per-frame basis. Short or incompressible frames are sent plaintext.
|
|
23
|
+
- **Zero-config option**: `dict:auto` trains a dictionary from the first 1000 messages (or 100 KiB, whichever hits first) and ships it via the `DICT` command frame.
|
|
24
|
+
|
|
25
|
+
## Non-goals
|
|
26
|
+
|
|
27
|
+
- A new socket type or a new ZMTP mechanism.
|
|
28
|
+
- Compression over `inproc://`. Zero-copy + compression is pure overhead.
|
|
29
|
+
- Compression over `ipc://`. Deferred for a future revision.
|
|
30
|
+
- Replacing CurveZMQ or any security layer. Compression and encryption interact in well-known dangerous ways (see RFC §Security Considerations).
|
|
31
|
+
- Locking the negotiation surface to Zstd. The READY property is `X-Compression`; profile strings carry an algorithm prefix (`zstd:none`, `zstd:dict:sha1:<hex>`, …) so future RFCs can add `lz4:`, `brotli:`, etc. without a new property.
|
|
32
|
+
|
|
33
|
+
## Usage (target API)
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
require "omq"
|
|
37
|
+
require "omq/rfc/zstd"
|
|
38
|
+
|
|
39
|
+
# 1. No dictionary — opportunistic compression for frames ≥ 512 B
|
|
40
|
+
push = OMQ::PUSH.new
|
|
41
|
+
push.compression = OMQ::RFC::Zstd::Compression.none
|
|
42
|
+
push.connect("tcp://127.0.0.1:5555")
|
|
43
|
+
|
|
44
|
+
# 2. Caller-supplied dictionary, agreed out of band
|
|
45
|
+
dict = File.binread("schema.dict")
|
|
46
|
+
push.compression = OMQ::RFC::Zstd::Compression.with_dictionary(dict)
|
|
47
|
+
|
|
48
|
+
# 3. Caller-supplied dictionary, sent over the wire once via DICT command
|
|
49
|
+
push.compression = OMQ::RFC::Zstd::Compression.with_dictionary(dict, inline: true)
|
|
50
|
+
|
|
51
|
+
# 4. Auto-trained dictionary — zero config
|
|
52
|
+
push.compression = OMQ::RFC::Zstd::Compression.auto
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The default level is **3**. Pass `level:` to override (negative levels enable
|
|
56
|
+
the fast strategy; see RFC §3.4).
|
|
57
|
+
|
|
58
|
+
## Status of the implementation
|
|
59
|
+
|
|
60
|
+
| Part | Status |
|
|
61
|
+
|------|--------|
|
|
62
|
+
| RFC | Draft |
|
|
63
|
+
| Frame-format codec (encode/decode one part) | Implemented |
|
|
64
|
+
| `OMQ::Options` extension (`compression=`) | Implemented |
|
|
65
|
+
| Handshake property injection | Implemented |
|
|
66
|
+
| `Connection#receive_message` / send seam | Implemented |
|
|
67
|
+
| `DICT` command frame (`dict:inline`, `dict:auto`) | Implemented |
|
|
68
|
+
| Integration test (real OMQ socket pair) | Implemented |
|
|
69
|
+
| omq-cli integration (`-z` / `-Z` / `--compress=LEVEL`) | Implemented |
|
|
70
|
+
|
|
71
|
+
## Development
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
OMQ_DEV=1 bundle install
|
|
75
|
+
OMQ_DEV=1 bundle exec rake test
|
|
76
|
+
OMQ_DEV=1 bundle exec ruby --yjit bench/level_sweep.rb
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
[ISC](LICENSE)
|