Documentation
¶
Overview ¶
Package gateway is the read gateway: a Loki API in front of a stock Loki that marks every line it returns verified or unverified, checked against the interval roots an archive holds, and answers each stream's coverage (intervals proven, holes, retraction receipts). Grafana points at it as at Loki (docs/backend.md).
Index ¶
Constants ¶
const ( LabelState = "blogs_state" LabelReason = "blogs_reason" )
The names a returned line's mark is given: a stream label when Loki answers with labels merged, structured metadata when the client asks for categorized labels (Grafana does).
const ( Verified = "verified" Unverified = "unverified" )
The marks.
const ( // ReasonPending: no interval proven in the archive covers the line's // batch yet. ReasonPending = "pending" // ReasonAltered: the line is not the one at its position in the batch // the root commits. ReasonAltered = "altered" // ReasonRelabeled: the line is, but the store's labels or time differ // from those the line carries. ReasonRelabeled = "relabeled" // ReasonRetracted: the batch was retracted; its receipt is in the // archive and the anchor still commits the position. ReasonRetracted = "retracted" // ReasonHole: the root commits the position and the archive never held // the batch. ReasonHole = "hole" // ReasonNoProvenance: the line carries no placement at all. ReasonNoProvenance = "no-provenance" // ReasonUnreadable: the archive's files for the batch could not be // read or did not verify. ReasonUnreadable = "unreadable" )
The reasons a line is unverified.
Variables ¶
This section is empty.
Functions ¶
func DeclareMetrics ¶
DeclareMetrics declares the gateway's metrics.
Types ¶
type Coverage ¶
type Coverage struct {
Stream string `json:"stream"`
Producer string `json:"producer"`
Intervals uint64 `json:"intervals"`
Proven []Span `json:"proven"`
Holes []uint64 `json:"holes"`
Retracted []Receipt `json:"retracted"`
// Refused are interval files whose paths do not lead to their root.
Refused map[string]string `json:"refused,omitempty"`
}
Coverage is one stream's state in the archive.
type Gateway ¶
type Gateway struct {
Loki *url.URL
Verifier *Verifier
Metrics *metrics.Set
Note func(format string, args ...any)
// contains filtered or unexported fields
}
Gateway is the Loki API in front of Loki.
func (*Gateway) Annotate ¶
Annotate marks every line of a Loki query answer of streams; any other answer is returned as it is.
type Receipt ¶
type Receipt struct {
Seq uint64 `json:"seq"`
Commitment string `json:"commitment"`
Sweep string `json:"sweep"`
SweepHeight uint32 `json:"sweepHeight"`
}
Receipt is a retracted position and the sweep that retracted it.
type Span ¶
type Span struct {
Interval uint64 `json:"interval"`
First uint64 `json:"first"`
Last uint64 `json:"last"`
Root string `json:"root"`
Token string `json:"token"`
Height uint32 `json:"height"`
}
Span is one proven interval.
type Verifier ¶
type Verifier struct {
// Dir is the archive's root: streams are under Dir/<stream>/<producer>.
Dir string
// Fetch finds digest-only content.
Fetch reader.Fetch
// Rescan is how stale the interval list may be before a line past its
// end makes it read again.
Rescan time.Duration
// contains filtered or unexported fields
}
Verifier checks lines against an archive directory (blogs archive -dir).
func (*Verifier) Check ¶
func (v *Verifier) Check(ctx context.Context, meta map[string]string, line, ts string, labels map[string]string) Verdict
Check marks one line the store answered: its placement (from structured metadata), its text, its time in nanoseconds as the store gives it, and the store's labels for it.