1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""RedEX wrapper — append-only per-channel log layer.
Sits on top of the PyO3 binding at ``net._net``. Adds:
- Re-exports of :class:`Redex`, :class:`RedexFile`, :class:`RedexEvent`,
:class:`RedexTailIter`, :class:`RedexError` so consumers can
`from net_sdk.redex import Redex` instead of reaching into the
raw binding.
- :func:`open_file_cm` — context-manager helper around
``Redex.open_file`` so a caller can ``with open_file_cm(redex,
"audit") as f:`` and the file closes on scope exit.
Example::
import net_sdk.redex as redex
r = redex.Redex(persistent_dir="/var/lib/net/redex")
with redex.open_file_cm(r, "orders/audit", persistent=True) as f:
seq = f.append(b"hello")
events = list(f.read_range(0, f.len()))
"""
# The PyO3 module exports these only when the wheel is built with the
# `cortex` Cargo feature. Importing from `net` (not `net._net`) keeps
# the public surface single-source.
# pragma: no cover — surface a clean message
=
"""Open a RedEX file and close it on scope exit.
``config`` keyword arguments mirror :class:`RedexFileConfig` —
``persistent``, ``fsync_policy``, ``retention_max_events``,
``retention_max_bytes``, ``retention_max_age_secs``,
``tail_buffer_size``, ``replication``. See ``redex.md`` in the
`net-event-bus` skill for the full kwargs surface.
"""
=
yield
# Idempotent close — file may already be closed by another caller.
pass