model

package
v0.45.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package model is SPECTRE's data model: the traffic that crosses a service's boundary through its proxies, and why a candidate was quarantined.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Direction

type Direction string

Direction names the proxy that carries traffic: ingress into the service, or egress from it to a dependency.

const (
	// Ingress traffic is requests to the proxied service.
	Ingress Direction = "ingress"
	// Egress traffic is requests from the service to a dependency.
	Egress Direction = "egress"
)

type Divergence

type Divergence struct {
	Service     string `json:"service"`
	Environment string `json:"environment"`
	// Revision is the commit of the candidate the mirror runs.
	Revision string `json:"revision"`
	// Direction is the proxy that quarantined the candidate.
	Direction  Direction  `json:"direction"`
	Quarantine Quarantine `json:"quarantine"`
}

Divergence is the quarantine that the mirror of a service environment reported for one of its directions.

type DivergenceFilter

type DivergenceFilter struct {
	Service     Option[string]
	Environment Option[string]
	Revision    Option[string]
	// Node matches only divergences on routes of that migration state node.
	Node Option[string]
}

DivergenceFilter selects divergences. An absent field matches every value.

func (DivergenceFilter) Matches

func (f DivergenceFilter) Matches(divergence Divergence) bool

Matches reports whether divergence passes every field of the filter.

type IOKind

type IOKind struct {
	Direction Direction
	Protocol  Protocol
}

IOKind is one kind of IO that a proxy intercepts, written "ingress[http]".

func (IOKind) String

func (k IOKind) String() string

String returns the kind as written in the migration state, e.g. "ingress[http]".

type Protocol

type Protocol string

Protocol names the protocol that a proxy intercepts, e.g. "http".

const ProtocolHTTP Protocol = "http"

ProtocolHTTP is the protocol of HTTP servers, including gRPC and Connect.

type Quarantine

type Quarantine struct {
	Reason QuarantineReason `json:"reason"` //nolint:narrowdeps // Other packages read the whole reason.
	Since  time.Time        `json:"since"`
}

Quarantine is a quarantine in effect: why it began and when.

type QuarantineKind

type QuarantineKind string

QuarantineKind is why the candidate was quarantined.

const (
	// QuarantineDivergent means the candidate's responses differ from the reference's.
	QuarantineDivergent QuarantineKind = "divergent"
	// QuarantineUnable means the mirror could not compare or replay traffic.
	QuarantineUnable QuarantineKind = "unable"
	// QuarantineUnmatched means the candidate made a dependency request the reference did not.
	QuarantineUnmatched QuarantineKind = "unmatched"
	// QuarantineUnlisted means an ingress route is in no node of the migration state.
	QuarantineUnlisted QuarantineKind = "unlisted"
	// QuarantineCapacity means candidate work exceeded a concurrency or buffer limit.
	QuarantineCapacity QuarantineKind = "capacity"
	// QuarantinePairing means the mirror could not pair candidate and reference traffic.
	QuarantinePairing QuarantineKind = "pairing"
)

type QuarantineReason

type QuarantineReason struct {
	Kind QuarantineKind `json:"kind"`
	// Traffic is the request that triggered quarantine.
	Traffic Option[Traffic] `json:"traffic,omitzero"`
	// Node is the migration state node that owns an ingress route.
	Node Option[string] `json:"node,omitzero"`
	// Differences are the field paths of a divergence, without values.
	Differences []string `json:"differences,omitempty"`
	Detail      string   `json:"detail,omitempty"`
}

QuarantineReason is why the candidate was quarantined. Detail and Differences must never quote payload values, because reasons are reported outside the mirror.

func (QuarantineReason) String

func (r QuarantineReason) String() string

String describes the reason for logs.

type Route

type Route string

Route is a protocol's canonical request route, e.g. "GET forecasts.example/v1/forecasts/{location}". Equal routes must have identical text, because egress pairing hashes it.

type Traffic

type Traffic struct {
	Direction Direction `json:"direction"`
	Protocol  Protocol  `json:"protocol"`
	Route     Route     `json:"route"`
}

Traffic identifies one request route of a kind of IO.

func (*Traffic) UnmarshalJSON

func (t *Traffic) UnmarshalJSON(data []byte) error

UnmarshalJSON rejects unknown fields. Option decodes with json.Unmarshal, so a reason's traffic must enforce strict decoding itself.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL