Documentation
¶
Overview ¶
Package shadowsamples stores the sanitized shadow-mode mismatch samples package hosts report, and serves them to the route-mode administration.
A package host (sdk/pluginhostsdk.Router) keeps its latest mismatches, sanitized by sdk/shadowsample, in the shadow_samples list of its Health details document. The kernel polls Health; Collector reads the samples from each poll, drops those for routes the package does not own in the package extraction map, sanitizes every field again, replaces the path with the route's path template, and stores each sample once. A host has no other way to write the table, and only the fixed sample columns.
Retention: samples are deleted after Retention, and only the newest MaxPerRoute of a route are kept.
Index ¶
Constants ¶
const ( // Retention is how long a sample is kept. Retention = 7 * 24 * time.Hour // MaxPerRoute is how many samples of one route are kept. MaxPerRoute = 100 // MaxPerReport bounds the samples read from one Health details // document; a host reports at most 32. MaxPerReport = 32 )
const DefaultLimit = 50
DefaultLimit is how many samples List returns without a limit.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collector ¶
type Collector struct {
DB *gorm.DB
// Route looks a route up in the package extraction map.
Route func(routeID string) (RouteInfo, bool)
// Now defaults to time.Now.
Now func() time.Time
// contains filtered or unexported fields
}
Collector stores the samples of Health reports.
type Filter ¶
type Filter struct {
PackageID string
RouteID string
// Limit defaults to DefaultLimit and is at most MaxPerRoute.
Limit int
}
Filter selects samples.
type Report ¶
type Report struct {
PackageID string
Version string
DetailsJSON string
// CheckedAt is when the kernel read the document; Collect skips a
// report it has already read.
CheckedAt time.Time
}
Report is one package host's Health details document.
type RouteInfo ¶
RouteInfo is what the kernel knows about a package route from the package extraction map.
type Sample ¶
type Sample struct {
ID uint `json:"id"`
SampleID string `json:"sample_id"`
PackageID string `json:"package_id"`
PackageVersion string `json:"package_version"`
RouteID string `json:"route_id"`
Method string `json:"method"`
Path string `json:"path"`
LegacyStatus int `json:"legacy_status"`
NativeStatus int `json:"native_status"`
Diff []shadowsample.DiffEntry `json:"diff"`
DiffTruncated bool `json:"diff_truncated"`
RequestID string `json:"request_id"`
ObservedAt time.Time `json:"observed_at"`
}
Sample is a stored sample as the administration shows it.