Documentation
¶
Overview ¶
Package state stores FerretDB process state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider provides access to FerretDB process state.
func NewProvider ¶
NewProvider creates a new Provider that stores state in the given file.
If filename is empty, then the state is not persisted.
All provider's methods are thread-safe.
func (*Provider) Get ¶
Get returns a copy of the current process state.
It is okay to call this function often. The caller should not cache result; Provider does everything needed itself.
func (*Provider) MetricsCollector ¶
func (p *Provider) MetricsCollector(addUUIDToMetric bool) prometheus.Collector
MetricsCollector returns Prometheus metrics collector for that provider.
If addUUIDToMetric is true, then the UUID is added to the Prometheus metric.
type State ¶
type State struct {
UUID string `json:"uuid"`
Telemetry *bool `json:"telemetry,omitempty"` // nil for undecided
TelemetryLocked bool `json:"-"`
Start time.Time `json:"-"`
// may be empty if FerretDB did not connect to the backend yet
BackendName string `json:"-"`
BackendVersion string `json:"-"`
// as reported by beacon, if known
LatestVersion string `json:"-"`
UpdateAvailable bool `json:"-"`
}
State represents FerretDB process state.
func (*State) DisableTelemetry ¶
func (s *State) DisableTelemetry()
DisableTelemetry disables telemetry.
It also sets LatestVersion and UpdateAvailable to zero values to avoid stale values when telemetry is re-enabled.
func (*State) EnableTelemetry ¶
func (s *State) EnableTelemetry()
EnableTelemetry enables telemetry.
func (*State) TelemetryString ¶
TelemetryString returns "enabled", "disabled" or "undecided".