share

package
v0.5.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNegativeInterval = errors.New("interval must be positive")
)

Functions

func CacheAvailability

func CacheAvailability[A share.Availability](lc fx.Lifecycle, ds datastore.Batching, avail A) share.Availability

CacheAvailability wraps either Full or Light availability with a cache for result sampling.

func ConstructModule

func ConstructModule(tp node.Type, cfg *Config, options ...fx.Option) fx.Option

func Discovery

func Discovery(cfg Config) func(routing.ContentRouting, host.Host) *discovery.Discovery

Types

type API added in v0.5.0

type API struct {
	SharesAvailable           func(context.Context, *share.Root) error
	ProbabilityOfAvailability func() float64
	GetShare                  func(ctx context.Context, dah *share.Root, row, col int) (share.Share, error)
	GetShares                 func(ctx context.Context, root *share.Root) ([][]share.Share, error)
	GetSharesByNamespace      func(ctx context.Context, root *share.Root, namespace namespace.ID) ([]share.Share, error)
}

API is a wrapper around Module for the RPC. TODO(@distractedm1nd): These structs need to be autogenerated.

type Config

type Config struct {
	// PeersLimit defines how many peers will be added during discovery.
	PeersLimit uint
	// DiscoveryInterval is an interval between discovery sessions.
	DiscoveryInterval time.Duration
	// AdvertiseInterval is a interval between advertising sessions.
	// NOTE: only full and bridge can advertise themselves.
	AdvertiseInterval time.Duration
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) Validate

func (cfg *Config) Validate() error

Validate performs basic validation of the config.

type Module

type Module interface {
	share.Availability
	GetShare(ctx context.Context, dah *share.Root, row, col int) (share.Share, error)
	GetShares(ctx context.Context, root *share.Root) ([][]share.Share, error)
	GetSharesByNamespace(ctx context.Context, root *share.Root, namespace namespace.ID) ([]share.Share, error)
}

Module provides access to any data square or block share on the network.

All Get methods provided on Module follow the following flow:

  1. Check local storage for the requested Share.
  2. If exists * Load from disk * Return
  3. If not * Find provider on the network * Fetch the Share from the provider * Store the Share * Return

Any method signature changed here needs to also be changed in the API struct.

func NewModule

func NewModule(lc fx.Lifecycle, bServ blockservice.BlockService, avail share.Availability) Module

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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