Documentation
¶
Overview ¶
Package ledgererr bounds the diagnostic text a ledger writes to its error column. The outbox's relay and the inbox's hold both persist an error whose text is not theirs — err.Error() from a broker, a driver or a consumer's own handler — into a column both ledgers declare unbounded.
Index ¶
Constants ¶
const MaxBytes = 1024
MaxBytes bounds the diagnostic text a ledger writes to its error column. Both ledgers declare that column unbounded (`error TEXT` on PostgreSQL, `error_msg CLOB` on Oracle), and the value written there is not ours: it is err.Error() from a broker or driver, which can carry server-supplied text of any length. A record that keeps failing rewrites the column every cycle, so an unbounded error is unbounded storage per retry, on the one table a service cannot drop.
1 KiB holds a broker error with its context and truncates only the pathological.
const TruncationMarker = "...[truncated]"
TruncationMarker is appended in place of the bytes dropped, so a reader can tell a short error from a shortened one.
Variables ¶
This section is empty.
Functions ¶
func Bound ¶
Bound makes an arbitrary error string safe to store.
Unlike an inbound trace identifier — where truncation silently forges correlation by mapping distinct upstream ids onto one, so a bad value is DISCARDED — this text is diagnostic and nothing keys on it. A truncated error still says what went wrong, while discarding one would throw away the only record of why a record is stuck. So truncation is the right answer here, and the marker keeps it honest.
Three things happen, in order:
- Invalid UTF-8 is dropped. PostgreSQL rejects it outright, which would fail the UPDATE and leave retry_count un-advanced — a record retrying forever because the framework could not write down why it failed.
- Control bytes become spaces. This text is read back into logs and dashboards, and a broker-supplied newline should not be able to forge a log line there. Only control bytes: ToValidUTF8 has already removed every invalid sequence, so a U+FFFD reaching here is one the sender actually wrote, and substituting it would drop a character nothing is wrong with.
- The result is capped without leaving a half-encoded character in the column.
Types ¶
This section is empty.