providers

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const ProvidersKeyPrefix = "/providers/"

ProvidersKeyPrefix is the prefix/namespace for ALL provider record keys stored in the data store.

Variables

View Source
var ProvideValidity = time.Hour * 24

ProvideValidity is the default time that a provider record should last

Functions

This section is empty.

Types

type Option

type Option func(*ProviderManager) error

Option is a function that sets a provider manager option.

func Cache

func Cache(c lru.LRUCache) Option

Cache sets the LRU cache implementation. Defaults to a simple LRU cache.

func CleanupInterval

func CleanupInterval(d time.Duration) Option

CleanupInterval sets the time between GC runs. Defaults to 1h.

type ProviderManager

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

ProviderManager adds and pulls providers out of the datastore, caching them in between

func NewProviderManager

func NewProviderManager(ctx context.Context, local peer.ID, dstore ds.Batching, opts ...Option) (*ProviderManager, error)

NewProviderManager constructor

func (*ProviderManager) AddProvider

func (pm *ProviderManager) AddProvider(ctx context.Context, k []byte, val peer.ID)

AddProvider adds a provider

func (*ProviderManager) GetProviders

func (pm *ProviderManager) GetProviders(ctx context.Context, k []byte) []peer.ID

GetProviders returns the set of providers for the given key. This method _does not_ copy the set. Do not modify it.

func (*ProviderManager) Process

func (pm *ProviderManager) Process() goprocess.Process

Process returns the ProviderManager process

Jump to

Keyboard shortcuts

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