Repository navigation
Commit 642454c
Add syslog stream and datagram listeners (#9)
* Add syslog stream and datagram listeners
Adds two syslog transports to the server alongside HTTP, both delivering
complete messages to a Ruby handler on the existing worker threads:
- a stream listener (Unix socket or TCP) framed with RFC 6587 octet
counting and a newline fallback, with optional PROXY v2 parsing to
recover the peer address, and
- a UDP listener with SO_REUSEPORT where one datagram is one message,
with receive-buffer truncation detected and dropped.
Undelivered messages are bounded per connection and overall; a refused
message stalls stream reads and is retried, while a refused datagram is
dropped and counted. Listener readiness and transport counters are
exposed as syslog_listening? and syslog_stats.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Share worker threads fairly between requests and syslog
The worker fast path always drained requests first, so sustained request
load could starve syslog delivery indefinitely and stall every sender
behind the per-connection backpressure. The two channels now alternate
which is asked first, and the blocking select already picks uniformly
between them. Workers with no syslog listener configured keep the
original single-channel path.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Apply syslog listener review fixes
Licence: the framing module, including its test data, is a port of
Vector 0.48.0's octet counting decoder, so the file, the README and the
licence file record that it is MPL-2.0 rather than MIT.
Framing: a read boundary landing on a digit inside an oversize body no
longer restarts octet counting and hands that body over as messages.
Delivery: the per-connection queue is bounded separately from the
listener-wide one, so a stalled sender cannot take every credit; the
handler is given a stable message id and attempt number, its exceptions
are counted apart from refusals, and retries end when shutdown starts.
Messages the drain could not admit are counted instead of vanishing.
Lifecycle: a cancellation token replaces the per-connection broadcast so
a connection accepted in the same round as the shutdown still sees it,
and stop() takes owned handles before releasing the GVL. Connection and
idle limits bound stream resources, and datagram receive errors back
off. A PROXY header naming a Unix or unspecified family falls back to
the transport peer, with read failures counted separately.
Workers may take several syslog messages per request, so a busy request
queue cannot pace syslog delivery. The handler now reports :stream or
:datagram, a peerless stream gives nil, the datagram buffer keys are
named for what they bound, and the handler stays reachable through the
server object rather than a permanent GC root.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Yield syslog messages to the worker block
Requests and syslog messages now reach Ruby the same way: the block
given to run_worker receives either a Request, which it answers with a
Response, or a SyslogMessage, which it answers with an admission
verdict. The separate configured handler, and the GC root it needed, are
gone; delivery, limits, retries and accounting are unchanged.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Declare both of the gem's licences
The framing module is MPL-2.0 while the rest is MIT, so the gem metadata
lists both.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Tighten how a syslog message is answered and held
A block that answers a syslog message with a response was not giving a
verdict, but its response read as truthy and admitted the message. That
now logs once and refuses, counted as a handler error, and the failure
log names the message and its transport.
The message object is freed as soon as it is collected and reports its
payload to the GC, its string is built without revalidating bytes the
framer already checked, and inspect prints the transport as the reader
returns it.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
* Correct the syslog and licence notes
The README described the removed callable, and the extension manifest
named only one of the two licences the gem declares.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>1 parent 13390c8 commit 642454c
12 files changed
Lines changed: 2826 additions & 24 deletions
File tree
- ext/hyper_ruby
- src
- syslog
- lib
- test
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
13 | 21 | | |
14 | 22 | | |
15 | 23 | | |
16 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
17 | 30 | | |
18 | 31 | | |
19 | 32 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
0 commit comments