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

provider

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckHealth

func CheckHealth(ctx context.Context, serviceURL string, timeout time.Duration) string

CheckHealth performs a PDP ping against the given service URL and returns "reachable", "unreachable", or "n/a" (for empty URLs).

func CheckHealthBatch

func CheckHealthBatch(ctx context.Context, providers []ProviderDetail, timeout time.Duration)

CheckHealthBatch performs concurrent health checks on all providers in the slice, updating each provider's HealthStatus in place. The concurrency is bounded to avoid overwhelming the network.

func FormatSize

func FormatSize(b *big.Int) string

FormatSize converts a byte count to a human-readable size string (e.g., "1 MiB", "32 GiB").

Types

type HealthChecker

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

HealthChecker performs provider health probes with a reusable HTTP client.

func NewHealthChecker

func NewHealthChecker(client *http.Client, formatters ...func(error) string) *HealthChecker

NewHealthChecker creates a provider health checker.

func (*HealthChecker) Check

func (h *HealthChecker) Check(ctx context.Context, serviceURL string, timeout time.Duration) string

Check performs a single provider health probe and returns its status.

func (*HealthChecker) Probe

func (h *HealthChecker) Probe(ctx context.Context, serviceURL string, timeout time.Duration) HealthResult

Probe performs a single provider health probe and explains a failure.

type HealthResult

type HealthResult struct {
	Status string
	Detail string
}

HealthResult is the outcome of one provider health probe. Status is "reachable", "unreachable", or "n/a" (no service URL). Detail explains a failed probe to operators with a redacted diagnostic.

type ListOptions

type ListOptions struct {
	ActiveOnly bool
}

ListOptions controls provider listing behavior.

type PartialListError

type PartialListError struct{ Failures []error }

PartialListError reports provider lookups omitted from a partial result.

func (*PartialListError) Error

func (e *PartialListError) Error() string

func (*PartialListError) Unwrap

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

type ProviderDetail

type ProviderDetail struct {
	ID                types.OnChainID   `json:"id"`
	Name              string            `json:"name"`
	Description       string            `json:"description,omitempty"`
	Active            bool              `json:"active"`
	Address           common.Address    `json:"address"`
	Payee             common.Address    `json:"payee"`
	HasPDP            bool              `json:"has_pdp"`
	ServiceURL        string            `json:"service_url,omitempty"`
	MinPieceSize      *big.Int          `json:"min_piece_size,omitempty"`
	MaxPieceSize      *big.Int          `json:"max_piece_size,omitempty"`
	StoragePrice      *big.Int          `json:"storage_price,omitempty"`
	MinProvingPeriod  *big.Int          `json:"min_proving_period,omitempty"`
	PaymentToken      common.Address    `json:"payment_token"`
	IPNIPiece         bool              `json:"ipni_piece"`
	IPNIIPFS          bool              `json:"ipni_ipfs"`
	IPNIPeerID        string            `json:"ipni_peer_id,omitempty"`
	ExtraCapabilities map[string][]byte `json:"extra_capabilities,omitempty"`
	Location          string            `json:"location,omitempty"`
	HealthStatus      string            `json:"health_status"`
}

ProviderDetail is the enriched output combining provider info, PDP offering, and health status.

func ListProviders

func ListProviders(ctx context.Context, reg *RegistryService, opts ListOptions) ([]ProviderDetail, error)

ListProviders returns PDP providers, optionally filtered to active-only.

func LookupProvider

func LookupProvider(ctx context.Context, reg *RegistryService, providerID sdktypes.BigInt) (ProviderDetail, error)

type RegistryService

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

RegistryService wraps the synapse-go spregistry.Service for provider listing.

func NewRegistryService

func NewRegistryService(svc *spregistry.Service) *RegistryService

NewRegistryService creates a RegistryService from a synapse-go SPRegistry service.

Jump to

Keyboard shortcuts

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