Documentation
¶
Overview ¶
Package core defines Console's domain types: the vocabulary shared by every other package. It deliberately depends on nothing else in the project so it can be imported freely without creating cycles.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrConflict = errors.New("already exists")
ErrConflict is returned when creating an item whose key already exists.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned by stores and registries when a keyed item does not exist. Callers compare with errors.Is.
Functions ¶
This section is empty.
Types ¶
type Check ¶
type Check struct {
Component string `json:"component"`
State HealthState `json:"state"`
Message string `json:"message,omitempty"`
Latency time.Duration `json:"latency,omitempty"`
CheckedAt time.Time `json:"checked_at"`
}
Check is a single point-in-time health observation for a component.
type Component ¶
type Component struct {
Key string `json:"key"`
Name string `json:"name"`
Description string `json:"description"`
// Provider names the StatusProvider plugin that checks this component.
Provider string `json:"provider"`
Config map[string]string `json:"config,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Component is a monitored part of an application — an API, a worker, a database. Its current health is the latest Check result for it.
type Evaluation ¶
type Evaluation struct {
FlagKey string `json:"flag_key"`
Enabled bool `json:"enabled"`
// Variant is the served variant key, or "on"/"off" for a boolean flag.
Variant string `json:"variant"`
Value string `json:"value,omitempty"`
// Reason explains the outcome (e.g. "flag_disabled", "out_of_scope",
// "rollout", "default") — useful for debugging and the dashboard.
Reason string `json:"reason"`
}
Evaluation is the result of evaluating a flag for a subject.
type Event ¶
type Event struct {
Type EventType `json:"type"`
Title string `json:"title"`
Message string `json:"message,omitempty"`
// Component is set for component_* events; Flag for flag_changed.
Component string `json:"component,omitempty"`
Flag string `json:"flag,omitempty"`
// From/To carry the health transition for component_* events.
From HealthState `json:"from,omitempty"`
To HealthState `json:"to,omitempty"`
At time.Time `json:"at"`
}
Event is a notifiable occurrence fanned out to Notifiers. It is intentionally flat so any sink (Slack, webhook, email) can render it without extra lookups.
type EventType ¶
type EventType string
EventType classifies a notifiable change in Console.
const ( // EventComponentDown is emitted when a component transitions to down. EventComponentDown EventType = "component_down" // EventComponentDegraded is emitted when a component transitions to degraded. EventComponentDegraded EventType = "component_degraded" // EventComponentRecovered is emitted when a component returns to operational // from a down or degraded state. EventComponentRecovered EventType = "component_recovered" // EventFlagChanged is emitted when a flag is created, updated, or deleted. EventFlagChanged EventType = "flag_changed" )
type Flag ¶
type Flag struct {
Key string `json:"key"`
Description string `json:"description"`
Enabled bool `json:"enabled"`
Scope Scope `json:"scope"`
// Rollout is the percentage of subjects in scope that receive the "on"
// variant, 0..100. Evaluation is deterministic per (flag, subject).
Rollout int `json:"rollout"`
// Variants are the possible values the flag can serve. A boolean flag has
// none and is evaluated as on/off via Rollout. A multivariate flag lists
// its variants with relative weights.
Variants []Variant `json:"variants,omitempty"`
// Cohort names the cohort when Scope == ScopeCohort.
Cohort string `json:"cohort,omitempty"`
// Experiment names the linked experiment when Scope == ScopeExperiment.
Experiment string `json:"experiment,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Flag is a feature flag. The zero value is a disabled flag that serves its default variant to everyone.
type Health ¶
type Health struct {
State HealthState `json:"state"`
Components []Check `json:"components"`
CheckedAt time.Time `json:"checked_at"`
}
Health is an aggregate snapshot across components, suitable for a status page or the dashboard overview.
type HealthState ¶
type HealthState int
HealthState is the coarse health of a monitored target. The ordering matters: higher states are worse, so aggregating a set of checks is a max().
const ( StateUnknown HealthState = iota // not yet checked StateOperational // healthy StateDegraded // working but impaired StateDown // not working )
func (HealthState) String ¶
func (s HealthState) String() string
type Scope ¶
type Scope string
Scope describes the audience a flag's rollout applies to. It mirrors the audience model from the original Console wireframes (Beta/Experiment/Cohort/ Alpha/All) and is open-ended so plugins can introduce their own scopes.
type Subject ¶
type Subject struct {
Key string `json:"key"`
Attributes map[string]string `json:"attributes,omitempty"`
}
Subject is the entity a flag is evaluated for — typically an end user, but it can be any keyed actor (a service, a tenant). Attributes carry context used by scope and cohort matching.