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

providerselect

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: 6 Imported by: 0

Documentation

Overview

Package providerselect defines provider admission and ranking without I/O.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTrustedProvider                = errors.New("no eligible provider meets the required provider tier")
	ErrInventoryUnavailable             = errors.New("provider selection inventory unavailable")
	ErrCandidatesTemporarilyUnavailable = errors.New("storage providers are temporarily unavailable")
	ErrUploadSpeedTestsPending          = errors.New("provider upload speed tests are pending")
)

Functions

This section is empty.

Types

type Admission

type Admission struct {
	Tier       Tier
	TrustedIDs []types.OnChainID
	CheckedAt  *time.Time
}

Admission is selection-time evidence, never a persisted provider policy.

func (Admission) Satisfied

func (a Admission) Satisfied(remainingTrusted bool, targets ...types.OnChainID) bool

func (Admission) Trusted

func (a Admission) Trusted(id types.OnChainID) bool

type Candidate

type Candidate struct {
	ID                   types.OnChainID
	Active               bool
	HasPDP               bool
	HasProfile           bool
	Healthy              bool
	Fresh                bool
	ServiceURL           string
	ProfileURL           string
	Load                 int
	BytesPerSecond       int64
	TierListed           bool
	UploadSpeedSettled   bool
	TieBreak             uint64
	ObservationCheckedAt *time.Time
}

func Select

func Select(in Inventory, strategy Strategy, count int, excluded map[string]ExclusionReason, hasTrusted bool) ([]Candidate, error)

Select reserves a trusted candidate first when the remaining set needs one. Random values are supplied by the caller; they only break exact ranking ties.

func (Candidate) IneligibleReason

func (c Candidate) IneligibleReason() string

type ExclusionReason

type ExclusionReason string
const (
	ExclusionBucketInUse       ExclusionReason = "bucket_in_use"
	ExclusionPreviouslyUsed    ExclusionReason = "previously_used"
	ExclusionContextOpenFailed ExclusionReason = "context_open_failed"
	ExclusionSelected          ExclusionReason = "selected_this_round"
)

func (ExclusionReason) Valid

func (r ExclusionReason) Valid() bool

type IngressEntry

type IngressEntry struct {
	CopyIndex      int
	BytesPerSecond int64
}

func RankIngress

func RankIngress(entries []IngressEntry) []IngressEntry

RankIngress orders bound replicas by measured speed, then by replica slot.

type Inventory

type Inventory struct {
	Candidates          []Candidate
	Admission           Admission
	UploadSpeedRequired bool
}

type ProviderRejection

type ProviderRejection struct {
	ProviderID           types.OnChainID `json:"provider_id"`
	Reason               string          `json:"reason"`
	ObservationCheckedAt *time.Time      `json:"observation_checked_at,omitempty"`
}

type SelectionDiagnostics

type SelectionDiagnostics struct {
	Tier            Tier                `json:"tier"`
	TierCheckedAt   *time.Time          `json:"tier_checked_at,omitempty"`
	HasTrusted      bool                `json:"has_trusted"`
	RequestedCount  int                 `json:"requested_count"`
	EligibleCount   int                 `json:"eligible_count"`
	RejectedTotal   int                 `json:"rejected_total"`
	RejectedOmitted int                 `json:"rejected_omitted"`
	Rejections      []ProviderRejection `json:"rejections"`
	// contains filtered or unexported fields
}

func Diagnose

func Diagnose(in Inventory, count int, excluded map[string]ExclusionReason, hasTrusted bool) SelectionDiagnostics

Diagnose records the complete decision inputs without provider URLs or errors.

func (SelectionDiagnostics) NeedsRefresh

func (d SelectionDiagnostics) NeedsRefresh() bool

NeedsRefresh is computed from all selection obstacles before diagnostics are capped.

type SelectionError

type SelectionError struct {
	Kind        SelectionFailureKind
	Cause       error
	Diagnostics SelectionDiagnostics
}

func (*SelectionError) Error

func (e *SelectionError) Error() string

func (*SelectionError) Unwrap

func (e *SelectionError) Unwrap() []error

type SelectionFailureKind

type SelectionFailureKind string
const (
	SelectionRequiredTierEmpty  SelectionFailureKind = "required_tier_empty"
	SelectionRequiredTierInUse  SelectionFailureKind = "required_tier_in_use"
	SelectionTemporary          SelectionFailureKind = "temporarily_unavailable"
	SelectionProviderContext    SelectionFailureKind = "provider_context_unavailable"
	SelectionUploadSpeedPending SelectionFailureKind = "upload_speed_tests_pending"
)

func (SelectionFailureKind) Valid

func (k SelectionFailureKind) Valid() bool

type Strategy

type Strategy string
const (
	StrategyDistribution Strategy = "distribution"
	StrategySpeed        Strategy = "speed"
)

func (Strategy) Valid

func (s Strategy) Valid() bool

type Tier

type Tier string
const (
	TierApproved Tier = "approved"
	TierEndorsed Tier = "endorsed"
	TierNone     Tier = "none"
)

func (Tier) Valid

func (t Tier) Valid() bool

Jump to

Keyboard shortcuts

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