state

package
v1.24.3 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package state stores DocDB 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 DocDB process state.

func NewProvider

func NewProvider(filename string) (*Provider, error)

NewProvider creates a new Provider that stores state in the given file (that will be created automatically if needed).

If filename is empty, then the state is not persisted.

All provider's methods are thread-safe.

func NewProviderDir

func NewProviderDir(dir string) (*Provider, error)

NewProviderDir creates a new Provider that stores state in the state.json file in the given directory (that will be created automatically if needed).

func (*Provider) Get

func (p *Provider) Get() *State

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(addUUID bool) prometheus.Collector

MetricsCollector returns Prometheus metrics collector for that provider.

If addUUID is true, then the "uuid" label is added.

func (*Provider) Subscribe

func (p *Provider) Subscribe() chan struct{}

Subscribe returns a channel that would receive notifications on state changes. One notification would be scheduled immediately.

func (*Provider) Update

func (p *Provider) Update(update func(s *State)) error

Update gets the current state, calls the given function, updates state, and notifies all subscribers.

func (*Provider) Var

func (p *Provider) Var() expvar.Var

Var returns an unpublished expvar.Var for the state.

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 DocDB did not connect to PostgreSQL yet
	PostgreSQLVersion string `json:"-"`
	DocumentDBVersion string `json:"-"`

	// as reported by beacon, if known
	LatestVersion   string `json:"-"`
	UpdateInfo      string `json:"-"`
	UpdateAvailable bool   `json:"-"`
}

State represents DocDB process state.

func (*State) TelemetryString

func (s *State) TelemetryString() string

TelemetryString returns "enabled", "disabled" or "undecided".

Jump to

Keyboard shortcuts

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