Help us shape the future of Go! Take the 2026 Go Developer Survey

observability

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package observability owns the boundary between collected storage facts and product-facing health signals.

Collection adapters gather facts from providers, chain state, wallet-scoped data sets, local storage metadata, and task state. They should not decide how those facts affect operator attention beyond producing typed state rows.

Interpretation belongs in this package. Status, reason codes, freshness, item signals, summary signals, and readiness/attention policies are computed here so admin APIs and UI surfaces do not duplicate health semantics.

Presentation layers consume observations and policy outputs. They may choose labels, layout, and copy, but must not reimplement provider/data set status, freshness, or readiness rules.

Index

Constants

This section is empty.

Variables

View Source
var ErrChainScannerUnavailable = errString("chain data set scanner unavailable")
View Source
var ErrProviderNotFound = errors.New("provider not found")
View Source
var ErrProviderRefreshInProgress = errors.New("provider refresh in progress")

Functions

This section is empty.

Types

type ApprovedProviderSource

type ApprovedProviderSource interface {
	ReadApprovedProviderIDs(context.Context) ([]types.OnChainID, error)
}

type ChainDataSet

type ChainDataSet struct {
	DataSetID        types.OnChainID
	ClientDataSetID  *types.OnChainID
	ProviderID       types.OnChainID
	IsLive           bool
	IsManaged        bool
	ActivePieceCount *int64
	HasActivePieces  *bool
	Metadata         map[string]string
}

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

func NewChecker

func NewChecker(opts CheckerOptions) *Checker

func (*Checker) CheckDataSets

func (c *Checker) CheckDataSets(ctx context.Context, checkedAt time.Time, localDataSets []LocalDataSet) ([]DataSetState, error)

func (*Checker) CheckProvider

func (c *Checker) CheckProvider(ctx context.Context, checkedAt time.Time, id types.OnChainID) (ProviderState, error)

func (*Checker) CheckProviders

func (c *Checker) CheckProviders(ctx context.Context, checkedAt time.Time, localDataSets []LocalDataSet) ([]ProviderState, error)

type CheckerOptions

type CheckerOptions struct {
	ProviderSource ProviderSource
	ProviderHealth ProviderHealthFunc
	DataSetScanner DataSetScanner
	Timeout        time.Duration
	Concurrency    int
	Now            func() time.Time
	Logger         *slog.Logger
	ErrorFormatter func(error) string
}

type CollectionState

type CollectionState struct {
	bun.BaseModel `bun:"table:observability_collection_states"`

	CollectionType CollectionType `bun:"collection_type,pk,type:text" json:"collection_type"`
	LastCheckedAt  time.Time      `bun:"last_checked_at,nullzero,notnull" json:"last_checked_at"`
}

type CollectionType

type CollectionType string
const (
	CollectionProviders CollectionType = "providers"
	CollectionDataSets  CollectionType = "data_sets"
)

type CopyFacts

type CopyFacts struct {
	Status         model.StorageCopyStatus `json:"status"`
	ProviderID     *types.OnChainID        `json:"provider_id,omitempty"`
	LocalDataSetID *int64                  `json:"local_data_set_id,omitempty"`
	ChainDataSetID *types.OnChainID        `json:"chain_data_set_id,omitempty"`
	PieceID        *types.OnChainID        `json:"piece_id,omitempty"`
	RetrievalURL   *string                 `json:"retrieval_url,omitempty"`
	LastError      *string                 `json:"last_error,omitempty"`
}

type DataSetFacts

type DataSetFacts struct {
	LocalDataSetID   int64                      `json:"local_data_set_id"`
	BucketID         int64                      `json:"bucket_id"`
	BucketName       string                     `json:"bucket_name"`
	CopyIndex        int                        `json:"copy_index"`
	ProviderID       types.OnChainID            `json:"provider_id"`
	ChainDataSetID   *types.OnChainID           `json:"chain_data_set_id,omitempty"`
	ClientDataSetID  *types.OnChainID           `json:"client_data_set_id,omitempty"`
	LocalStatus      model.StorageDataSetStatus `json:"local_status"`
	ActivePieceCount *int64                     `json:"active_piece_count,omitempty"`
	HasActivePieces  *bool                      `json:"has_active_pieces,omitempty"`
}

type DataSetObservation

type DataSetObservation struct {
	Facts  DataSetFacts `json:"facts"`
	Signal Signal       `json:"signal"`
}

func DataSetObservationFromState

func DataSetObservationFromState(state DataSetState, interval time.Duration, now time.Time) DataSetObservation

type DataSetObservationPage

type DataSetObservationPage struct {
	Items         []DataSetObservation `json:"items"`
	Summary       Summary              `json:"summary"`
	SummarySignal SummarySignal        `json:"summary_signal"`
	Total         int                  `json:"total"`
	Limit         int                  `json:"limit"`
	Offset        int                  `json:"offset"`
}

type DataSetScanner

type DataSetScanner interface {
	ScanWalletDataSets(context.Context) ([]ChainDataSet, error)
}

type DataSetState

type DataSetState struct {
	bun.BaseModel `bun:"table:observability_data_set_states,alias:observability_data_set_state"`

	LocalDataSetID  int64            `bun:"local_data_set_id,pk" json:"local_data_set_id"`
	BucketID        int64            `bun:"bucket_id,notnull" json:"bucket_id"`
	CopyIndex       int              `bun:"copy_index,type:integer,notnull" json:"copy_index"`
	ProviderID      types.OnChainID  `bun:"provider_id,type:text,notnull" json:"provider_id"`
	ChainDataSetID  *types.OnChainID `bun:"chain_data_set_id,type:text" json:"chain_data_set_id,omitempty"`
	ClientDataSetID *types.OnChainID `bun:"client_data_set_id,type:text" json:"client_data_set_id,omitempty"`
	// BucketName and LocalStatus are projected from the rows that own them.
	// Observations are rebuilt wholesale on every refresh, so a copy here would
	// only add a second, staler answer to the same question.
	BucketName       string                     `bun:",scanonly" json:"bucket_name"`
	LocalStatus      model.StorageDataSetStatus `bun:",scanonly" json:"local_status"`
	Status           Status                     `bun:"status,type:text,notnull" json:"status"`
	ReasonCodes      []ReasonCode               `bun:"reason_codes,type:jsonb,notnull" json:"reason_codes"`
	ActivePieceCount *int64                     `bun:"active_piece_count,nullzero" json:"active_piece_count,omitempty"`
	LastCheckedAt    time.Time                  `bun:"last_checked_at,nullzero,notnull" json:"last_checked_at"`
	LastError        *string                    `bun:"last_error,type:text,nullzero" json:"last_error,omitempty"`
	Evidence         map[string]any             `bun:"evidence_json,type:jsonb,notnull" json:"evidence"`
}

type DataSetStatePage

type DataSetStatePage struct {
	Items         []DataSetState `json:"items"`
	Summary       Summary        `json:"summary"`
	LastCheckedAt *time.Time     `json:"last_checked_at,omitempty"`
	Total         int            `json:"total"`
	Limit         int            `json:"limit"`
	Offset        int            `json:"offset"`
}

type EndorsedProviderSource

type EndorsedProviderSource interface {
	GetEndorsedProviderIDs(context.Context) ([]sdktypes.BigInt, error)
}

type Flow

type Flow uint8

Flow identifies an object payload transfer boundary and direction.

const (
	ClientUpload Flow = iota
	ClientDownload
	StorageUpload
	StorageDownload
)

type Freshness

type Freshness struct {
	LastCheckedAt *time.Time         `json:"last_checked_at,omitempty"`
	Stale         bool               `json:"stale"`
	Warnings      []FreshnessWarning `json:"warnings"`
}

func BuildFreshness

func BuildFreshness(lastCheckedAt *time.Time, interval time.Duration, now time.Time) Freshness

type FreshnessWarning

type FreshnessWarning string
const (
	FreshnessNoStateRecorded FreshnessWarning = "no_state_recorded"
	FreshnessStaleState      FreshnessWarning = "stale_state"
)

type ListOptions

type ListOptions struct {
	Limit      int
	Offset     int
	Status     Status
	BucketID   int64
	ProviderID *types.OnChainID
}

type LocalDataSet

type LocalDataSet struct {
	ID              int64
	BucketID        int64
	BucketName      string
	CopyIndex       int
	ProviderID      types.OnChainID
	DataSetID       *types.OnChainID
	ClientDataSetID *types.OnChainID
	Status          model.StorageDataSetStatus
}

type LocalDataSetCountSource

type LocalDataSetCountSource interface {
	CountLocalDataSets(context.Context) (int, error)
}

type LocalDataSetCountSourceFunc

type LocalDataSetCountSourceFunc func(context.Context) (int, error)

func (LocalDataSetCountSourceFunc) CountLocalDataSets

func (f LocalDataSetCountSourceFunc) CountLocalDataSets(ctx context.Context) (int, error)

type LocalDataSetSource

type LocalDataSetSource interface {
	ListLocalDataSets(context.Context) ([]LocalDataSet, error)
}

type LocalDataSetSourceFunc

type LocalDataSetSourceFunc func(context.Context) ([]LocalDataSet, error)

func (LocalDataSetSourceFunc) ListLocalDataSets

func (f LocalDataSetSourceFunc) ListLocalDataSets(ctx context.Context) ([]LocalDataSet, error)

type MonitoringPoint

type MonitoringPoint struct {
	At                            time.Time `json:"at"`
	CPUCores                      *float64  `json:"cpu_cores"`
	RSSBytes                      *uint64   `json:"rss_bytes"`
	ClientUploadBytesPerSecond    *float64  `json:"client_upload_bytes_per_second"`
	ClientDownloadBytesPerSecond  *float64  `json:"client_download_bytes_per_second"`
	StorageUploadBytesPerSecond   *float64  `json:"storage_upload_bytes_per_second"`
	StorageDownloadBytesPerSecond *float64  `json:"storage_download_bytes_per_second"`
	GapBefore                     bool      `json:"gap_before"`
}

MonitoringPoint measures process resources and object payload transfer rates.

type MonitoringSnapshot

type MonitoringSnapshot struct {
	InstanceID       string            `json:"instance_id"`
	StartedAt        time.Time         `json:"started_at"`
	WindowStart      time.Time         `json:"window_start"`
	WindowEnd        time.Time         `json:"window_end"`
	SnapshotAt       time.Time         `json:"snapshot_at"`
	SampledAt        *time.Time        `json:"sampled_at"`
	IntervalSeconds  int               `json:"interval_seconds"`
	RetentionSeconds int               `json:"retention_seconds"`
	Status           MonitoringStatus  `json:"status"`
	Totals           TransferTotals    `json:"totals"`
	Points           []MonitoringPoint `json:"points"`
}

MonitoringSnapshot is an isolated copy of a runtime's bounded sample history.

type MonitoringStatus

type MonitoringStatus struct {
	CPU     string `json:"cpu"`
	RSS     string `json:"rss"`
	Traffic string `json:"traffic"`
}

MonitoringStatus describes the latest sample's metric availability.

type Provider

type Provider struct {
	ID           types.OnChainID
	Active       bool
	HasPDP       bool
	ServiceURL   string
	HealthStatus string
	Profile      *ProviderProfile
}

type ProviderFacts

type ProviderFacts struct {
	ProviderID   types.OnChainID `json:"provider_id"`
	Active       *bool           `json:"active,omitempty"`
	HasPDP       *bool           `json:"has_pdp,omitempty"`
	ServiceURL   *string         `json:"service_url,omitempty"`
	HealthStatus *string         `json:"health_status,omitempty"`
}

type ProviderHealth

type ProviderHealth = provider.HealthResult

ProviderHealth is one provider health probe result. A failed probe's Detail becomes the provider's last error.

type ProviderHealthFunc

type ProviderHealthFunc func(context.Context, string, time.Duration) ProviderHealth

type ProviderObservation

type ProviderObservation struct {
	Facts  ProviderFacts `json:"facts"`
	Signal Signal        `json:"signal"`
}

func ProviderObservationFromState

func ProviderObservationFromState(state ProviderState, interval time.Duration, now time.Time) ProviderObservation

type ProviderObservationPage

type ProviderObservationPage struct {
	Items         []ProviderObservation `json:"items"`
	Summary       Summary               `json:"summary"`
	SummarySignal SummarySignal         `json:"summary_signal"`
	Total         int                   `json:"total"`
	Limit         int                   `json:"limit"`
	Offset        int                   `json:"offset"`
}

type ProviderProfile

type ProviderProfile struct {
	bun.BaseModel          `bun:"table:provider_profiles"`
	ProviderID             types.OnChainID `bun:"provider_id,pk,type:text" json:"provider_id"`
	Name                   string          `bun:"name,type:text,notnull" json:"name"`
	Description            string          `bun:"description,type:text,notnull" json:"description"`
	ServiceProviderAddress string          `bun:"service_provider_address,type:text,notnull" json:"service_provider_address"`
	PayeeAddress           string          `bun:"payee_address,type:text,notnull" json:"payee_address"`
	Active                 bool            `bun:"active,notnull" json:"active"`
	ServiceURL             string          `bun:"service_url,type:text,notnull" json:"service_url"`
	RegistrySnapshot       json.RawMessage `bun:"registry_snapshot_json,type:jsonb,notnull" json:"registry_snapshot"`
	LastSuccessAt          time.Time       `bun:"last_success_at,notnull" json:"last_success_at"`
	Approved               bool            `bun:"-" json:"approved"`
	ApprovedCheckedAt      *time.Time      `bun:"-" json:"approved_checked_at"`
	Endorsed               bool            `bun:"-" json:"endorsed"`
	EndorsedCheckedAt      *time.Time      `bun:"-" json:"endorsed_checked_at"`
}

ProviderProfile is the last successful Registry read for one provider.

type ProviderSource

type ProviderSource interface {
	ListActiveProviders(context.Context) ([]Provider, error)
	LookupProvider(context.Context, types.OnChainID) (Provider, error)
}

type ProviderState

type ProviderState struct {
	bun.BaseModel `bun:"table:observability_provider_states"`
	Profile       *ProviderProfile `bun:"-" json:"-"`

	ProviderID    types.OnChainID `bun:"provider_id,pk,type:text" json:"provider_id"`
	Status        Status          `bun:"status,type:text,notnull" json:"status"`
	ReasonCodes   []ReasonCode    `bun:"reason_codes,type:jsonb,notnull" json:"reason_codes"`
	Active        *bool           `bun:"active" json:"active,omitempty"`
	HasPDP        *bool           `bun:"has_pdp" json:"has_pdp,omitempty"`
	ServiceURL    *string         `bun:"service_url,type:text" json:"service_url,omitempty"`
	HealthStatus  *string         `bun:"health_status,type:text" json:"health_status,omitempty"`
	LastCheckedAt time.Time       `bun:"last_checked_at,nullzero,notnull" json:"last_checked_at"`
	LastAttemptAt time.Time       `bun:"last_attempt_at,nullzero,notnull" json:"last_attempt_at"`
	LastError     *string         `bun:"last_error,type:text,nullzero" json:"last_error,omitempty"`
	Evidence      map[string]any  `bun:"evidence_json,type:jsonb,notnull" json:"evidence"`
}

type ProviderStatePage

type ProviderStatePage struct {
	Items         []ProviderState `json:"items"`
	Summary       Summary         `json:"summary"`
	LastCheckedAt *time.Time      `json:"last_checked_at,omitempty"`
	Total         int             `json:"total"`
	Limit         int             `json:"limit"`
	Offset        int             `json:"offset"`
}

type ProviderTierSnapshot

type ProviderTierSnapshot struct {
	bun.BaseModel `bun:"table:provider_tier_snapshots"`
	Tier          string          `bun:"tier,pk,type:text"`
	ProviderIDs   json.RawMessage `bun:"provider_ids_json,type:jsonb,notnull"`
	CheckedAt     time.Time       `bun:"checked_at,notnull"`
}

type ReasonCode

type ReasonCode string
const (
	ReasonRegistryLookupFailed    ReasonCode = "registry_lookup_failed"
	ReasonProviderInactive        ReasonCode = "provider_inactive"
	ReasonProviderMissingPDP      ReasonCode = "provider_missing_pdp"
	ReasonProviderHTTPUnreachable ReasonCode = "provider_http_unreachable"
	ReasonChainLookupFailed       ReasonCode = "chain_lookup_failed"
	ReasonChainDataSetMissing     ReasonCode = "chain_data_set_missing"
	ReasonChainDataSetInactive    ReasonCode = "chain_data_set_inactive"
	ReasonChainDataSetUnmanaged   ReasonCode = "chain_data_set_unmanaged"
	ReasonLocalStatusNotReady     ReasonCode = "local_status_not_ready"
	ReasonProviderMismatch        ReasonCode = "provider_mismatch"
	ReasonMetadataMismatch        ReasonCode = "metadata_mismatch"
	ReasonCopyUnderReplicated     ReasonCode = "copy_under_replicated"
	ReasonCopyPending             ReasonCode = "copy_pending"
	ReasonCopyCommitting          ReasonCode = "copy_committing"
	ReasonCopyFailed              ReasonCode = "copy_failed"
	ReasonCopyMissingProvider     ReasonCode = "copy_missing_provider"
	ReasonCopyMissingDataSet      ReasonCode = "copy_missing_data_set"
	ReasonCopyMissingPiece        ReasonCode = "copy_missing_piece"
	ReasonCopyMissingRetrievalURL ReasonCode = "copy_missing_retrieval_url"
	ReasonCopyObservationMissing  ReasonCode = "copy_observation_missing"
)

func AppendReasonCode

func AppendReasonCode(reasons []ReasonCode, reason ReasonCode) []ReasonCode

AppendReasonCode appends a non-empty reason code if it is not already present.

func (ReasonCode) String

func (r ReasonCode) String() string

type RefreshChecker

type RefreshChecker interface {
	CheckProviders(context.Context, time.Time, []LocalDataSet) ([]ProviderState, error)
	CheckDataSets(context.Context, time.Time, []LocalDataSet) ([]DataSetState, error)
}

type RegistryProviderSource

type RegistryProviderSource struct {
	// contains filtered or unexported fields
}

func NewRegistryProviderSource

func NewRegistryProviderSource(registry *provider.RegistryService) *RegistryProviderSource

func (*RegistryProviderSource) ListActiveProviders

func (s *RegistryProviderSource) ListActiveProviders(ctx context.Context) ([]Provider, error)

func (*RegistryProviderSource) LookupProvider

func (s *RegistryProviderSource) LookupProvider(ctx context.Context, id idtypes.OnChainID) (Provider, error)

type RuntimeMonitor

type RuntimeMonitor struct {
	// contains filtered or unexported fields
}

RuntimeMonitor keeps read-only telemetry in a bounded process-local history.

func NewRuntimeMonitor

func NewRuntimeMonitor(transfers *TransferCounters) *RuntimeMonitor

NewRuntimeMonitor creates telemetry sources without starting background work.

func (*RuntimeMonitor) Capture

func (m *RuntimeMonitor) Capture()

Capture records one sample; the first capture establishes rate baselines.

func (*RuntimeMonitor) Run

func (m *RuntimeMonitor) Run(ctx context.Context)

Run samples until cancelled; its owner captures the initial baseline first.

func (*RuntimeMonitor) Snapshot

func (m *RuntimeMonitor) Snapshot() MonitoringSnapshot

Snapshot copies the last sample's totals and the retained history atomically.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(opts ServiceOptions) *Service

func (*Service) DataSetObservationsByLocalIDs

func (s *Service) DataSetObservationsByLocalIDs(ctx context.Context, localIDs []int64) (map[int64]DataSetObservation, error)

func (*Service) DataSetStatesByLocalIDs

func (s *Service) DataSetStatesByLocalIDs(ctx context.Context, localIDs []int64) (map[int64]DataSetState, error)

func (*Service) ListDataSetObservations

func (s *Service) ListDataSetObservations(ctx context.Context, opts ListOptions) (DataSetObservationPage, error)

func (*Service) ListDataSets

func (s *Service) ListDataSets(ctx context.Context, opts ListOptions) (DataSetStatePage, error)

func (*Service) ListProviderObservations

func (s *Service) ListProviderObservations(ctx context.Context, opts ListOptions) (ProviderObservationPage, error)

func (*Service) ListProviders

func (s *Service) ListProviders(ctx context.Context, opts ListOptions) (ProviderStatePage, error)

func (*Service) ProviderCandidates

func (s *Service) ProviderCandidates(ctx context.Context) (providerselect.Inventory, error)

ProviderCandidates reads stored provider health, profiles, and tier membership.

func (*Service) ProviderProfile

func (s *Service) ProviderProfile(ctx context.Context, id types.OnChainID) (*ProviderProfile, error)

func (*Service) ProviderTiersAvailable

func (s *Service) ProviderTiersAvailable() bool

func (*Service) RefreshApprovedProviders

func (s *Service) RefreshApprovedProviders(ctx context.Context) (time.Time, time.Time, error)

RefreshApprovedProviders reads the approved tier and returns when the read started and the collection time of the snapshot stored afterwards. The two differ when a newer read committed first; the newer snapshot is kept.

func (*Service) RefreshDataSetObservations

func (s *Service) RefreshDataSetObservations(ctx context.Context, opts ListOptions) (DataSetObservationPage, error)

func (*Service) RefreshDataSetStates

func (s *Service) RefreshDataSetStates(ctx context.Context) error

func (*Service) RefreshDataSets

func (s *Service) RefreshDataSets(ctx context.Context, opts ListOptions) (DataSetStatePage, error)

func (*Service) RefreshEndorsedProviders

func (s *Service) RefreshEndorsedProviders(ctx context.Context) (time.Time, time.Time, error)

RefreshEndorsedProviders is RefreshApprovedProviders for the endorsed tier.

func (*Service) RefreshInterval

func (s *Service) RefreshInterval() time.Duration

func (*Service) RefreshMissingProviderTiers

func (s *Service) RefreshMissingProviderTiers(ctx context.Context) error

func (*Service) RefreshProvider

func (s *Service) RefreshProvider(ctx context.Context, id types.OnChainID) (ProviderState, error)

func (*Service) RefreshProviderObservations

func (s *Service) RefreshProviderObservations(ctx context.Context, opts ListOptions) (ProviderObservationPage, error)

func (*Service) RefreshProviderStates

func (s *Service) RefreshProviderStates(ctx context.Context) error

func (*Service) RefreshProviders

func (s *Service) RefreshProviders(ctx context.Context, opts ListOptions) (ProviderStatePage, error)

func (*Service) RefreshProvidersWithContext

func (s *Service) RefreshProvidersWithContext(ctx context.Context, opts ListOptions) (ProviderStatePage, error)

RefreshProvidersWithContext refreshes provider state using the caller context.

func (*Service) RefreshTimeout

func (s *Service) RefreshTimeout() time.Duration

func (*Service) SelectionAdmission

func (s *Service) SelectionAdmission(ctx context.Context, tier providerselect.Tier) (providerselect.Admission, error)

func (*Service) SelectionInventory

func (s *Service) SelectionInventory(ctx context.Context, tier providerselect.Tier) (providerselect.Inventory, error)

SelectionInventory reads health and a fresh, independent tier snapshot.

type ServiceOptions

type ServiceOptions struct {
	ApprovedProviders ApprovedProviderSource
	EndorsedProviders EndorsedProviderSource
	Checker           RefreshChecker
	LocalDataSets     LocalDataSetSource
	LocalDataSetCount LocalDataSetCountSource
	Store             StateStore
	RefreshInterval   time.Duration
	RefreshTimeout    time.Duration
	Now               func() time.Time
}

type Signal

type Signal struct {
	Status      Status       `json:"status"`
	Level       SignalLevel  `json:"level"`
	ReasonCodes []ReasonCode `json:"reason_codes"`
	LastError   *string      `json:"last_error,omitempty"`
	Freshness   Freshness    `json:"freshness"`
}

func BuildSignal

func BuildSignal(status Status, reasons []ReasonCode, lastError *string, lastCheckedAt *time.Time, interval time.Duration, now time.Time) Signal

func CopyHealthFromFacts

func CopyHealthFromFacts(facts CopyFacts, dataSetObservation *DataSetObservation, interval time.Duration, now time.Time) Signal

type SignalLevel

type SignalLevel string
const (
	SignalOK       SignalLevel = "ok"
	SignalWarning  SignalLevel = "warning"
	SignalBlocking SignalLevel = "blocking"
)

func WorstSignalLevel

func WorstSignalLevel(current SignalLevel, candidate SignalLevel) SignalLevel

type StateStore

type StateStore interface {
	ReplaceProviderStates(context.Context, time.Time, []ProviderState) error
	ListProviderStates(context.Context, ListOptions) (ProviderStatePage, error)
	ReplaceDataSetStates(context.Context, time.Time, []DataSetState) error
	ListDataSetStates(context.Context, ListOptions) (DataSetStatePage, error)
	GetDataSetStatesByLocalIDs(context.Context, []int64) (map[int64]DataSetState, error)
}

type Status

type Status string
const (
	StatusAvailable   Status = "available"
	StatusDegraded    Status = "degraded"
	StatusUnavailable Status = "unavailable"
	StatusUnknown     Status = "unknown"
)

func (Status) Valid

func (s Status) Valid() bool

Valid reports whether the value is a known status.

type StorageDataSetScanner

type StorageDataSetScanner struct {
	// contains filtered or unexported fields
}

func NewStorageDataSetScanner

func NewStorageDataSetScanner(storage dataSetFinder) *StorageDataSetScanner

func (*StorageDataSetScanner) ScanWalletDataSets

func (s *StorageDataSetScanner) ScanWalletDataSets(ctx context.Context) ([]ChainDataSet, error)

type Summary

type Summary struct {
	Total       int `json:"total"`
	Available   int `json:"available"`
	Degraded    int `json:"degraded"`
	Unavailable int `json:"unavailable"`
	Unknown     int `json:"unknown"`
}

type SummarySignal

type SummarySignal struct {
	Level     SignalLevel `json:"level"`
	Freshness Freshness   `json:"freshness"`
}

func DefaultAttentionSummarySignal

func DefaultAttentionSummarySignal(summary Summary, lastCheckedAt *time.Time, interval time.Duration, now time.Time) SummarySignal

type TransferByteTotals

type TransferByteTotals struct {
	UploadBytes   uint64 `json:"upload_bytes,string"`
	DownloadBytes uint64 `json:"download_bytes,string"`
}

TransferByteTotals holds cumulative payload bytes at one boundary.

type TransferCounters

type TransferCounters struct {
	// contains filtered or unexported fields
}

TransferCounters measures bytes actually read or written by payload streams.

func NewTransferCounters

func NewTransferCounters() *TransferCounters

NewTransferCounters creates isolated counters and their Prometheus gatherer.

func (*TransferCounters) Gatherer

func (c *TransferCounters) Gatherer() prometheus.Gatherer

Gatherer exposes only this instance's payload transfer counters.

func (*TransferCounters) Totals

func (c *TransferCounters) Totals() TransferTotals

Totals reads the cumulative counters without collecting Prometheus metrics.

func (*TransferCounters) WrapReadCloser

func (c *TransferCounters) WrapReadCloser(flow Flow, r io.ReadCloser) io.ReadCloser

WrapReadCloser counts reads and preserves the stream's Close behavior.

func (*TransferCounters) WrapReader

func (c *TransferCounters) WrapReader(flow Flow, r io.Reader) io.Reader

WrapReader counts bytes returned by Read, including partial failed reads.

func (*TransferCounters) WrapWriter

func (c *TransferCounters) WrapWriter(flow Flow, w io.Writer) io.Writer

WrapWriter counts bytes accepted by Write, including partial failed writes.

type TransferTotals

type TransferTotals struct {
	Client  TransferByteTotals `json:"client"`
	Storage TransferByteTotals `json:"storage"`
}

TransferTotals contains process-local cumulative payload bytes.

Jump to

Keyboard shortcuts

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