Documentation ¶
Index ¶
- Variables
- func RegToApiProviderInfo(pi *ProviderInfo) *model.ProviderInfo
- func Unfreeze(ctx context.Context, freezeDirs []string, freezeAtPercent float64, ...) (map[peer.ID]cid.Cid, error)
- type ContextualExtendedProviders
- type ExtendedProviderInfo
- type ExtendedProviders
- type Option
- type ProviderInfo
- type Registry
- func (r *Registry) AllProviderInfo() []*ProviderInfo
- func (r *Registry) AllowPeer(peerID peer.ID) bool
- func (r *Registry) Allowed(peerID peer.ID) bool
- func (r *Registry) AssignPeer(publisherID peer.ID) error
- func (r *Registry) BlockPeer(peerID peer.ID) bool
- func (r *Registry) CheckSequence(peerID peer.ID, seq uint64) error
- func (r *Registry) Close()
- func (r *Registry) FilterIPsEnabled() bool
- func (r *Registry) Freeze() error
- func (r *Registry) Frozen() bool
- func (r *Registry) Handoff(ctx context.Context, publisherID, frozenID peer.ID, frozenURL *url.URL) error
- func (r *Registry) ImportProviders(ctx context.Context, fromURL *url.URL) (int, error)
- func (r *Registry) IsRegistered(providerID peer.ID) bool
- func (r *Registry) ListAssignedPeers() ([]peer.ID, []peer.ID, error)
- func (r *Registry) ListPreferredPeers() ([]peer.ID, error)
- func (r *Registry) ProviderInfo(providerID peer.ID) (*ProviderInfo, bool)
- func (r *Registry) PublishAllowed(publisherID, providerID peer.ID) bool
- func (r *Registry) RemoveProvider(ctx context.Context, providerID peer.ID) error
- func (r *Registry) Saw(providerID peer.ID, clearError bool)
- func (r *Registry) SetLastError(providerID peer.ID, err error)
- func (r *Registry) SetMaxPoll(maxPoll int)
- func (r *Registry) SetPolicy(policyCfg config.Policy) error
- func (r *Registry) SyncChan() <-chan *ProviderInfo
- func (r *Registry) UnassignPeer(peerID peer.ID) (bool, error)
- func (r *Registry) Update(ctx context.Context, provider, publisher peer.AddrInfo, adCid cid.Cid, ...) error
- func (r *Registry) ValueStoreUsage() (*disk.UsageStats, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrAlreadyAssigned = errors.New("publisher already assigned to this indexer") ErrInProgress = errors.New("discovery already in progress") ErrCannotPublish = errors.New("publisher not allowed to publish to other provider") ErrFrozen = errors.New("indexer frozen") ErrMissingProviderAddr = errors.New("advertisement missing provider address") ErrNotAllowed = errors.New("peer not allowed by policy") ErrNoDiscovery = errors.New("discovery not available") ErrNoFreeze = errors.New("freeze not configured") ErrNotVerified = errors.New("provider cannot be verified") ErrPublisherNotAllowed = errors.New("publisher not allowed by policy") ErrTooSoon = errors.New("not enough time since previous discovery") ErrNoAssigner = errors.New("not configured to work with assigner service") )
Functions ¶
func RegToApiProviderInfo ¶ added in v0.5.5
func RegToApiProviderInfo(pi *ProviderInfo) *model.ProviderInfo
RegToApiProviderInfo converts provider info from registry to api objects.
func Unfreeze ¶ added in v0.5.5
func Unfreeze(ctx context.Context, freezeDirs []string, freezeAtPercent float64, dstore datastore.Datastore) (map[peer.ID]cid.Cid, error)
Unfreeze reverts the freezer and provider information back to its unfrozen state. This must only be called when the registry is not running.
Types ¶
type ContextualExtendedProviders ¶
type ContextualExtendedProviders struct { // Providers contains a list of context-level extended providers Providers []ExtendedProviderInfo // Override defines whether chain-level extended providers should be used // for this ContextID. If true, then the chain-level extended providers are // going to be ignored. Override bool // ContextID defines the context ID that the extended providers have been // published for ContextID []byte `json:",omitempty"` }
ContextualExtendedProviders holds information about a context-level extended providers. These can either replace or compliment (union) the chain-level extended providers, which is driven by the Override flag.
type ExtendedProviderInfo ¶
type ExtendedProviderInfo struct { // PeerID contains a peer.ID of the extended provider. PeerID peer.ID // Metadata contains a metadata override for this provider within the // extended provider context. If extended provider's metadata hasn't been // specified - the main provider's metadata is going to be used instead. Metadata []byte `json:",omitempty"` // Addrs contains advertised multiaddresses for this extended provider. Addrs []multiaddr.Multiaddr }
ExtendedProviderInfo is an immutable data structure that holds information about an extended provider.
func (*ExtendedProviderInfo) MarshalJSON ¶
func (p *ExtendedProviderInfo) MarshalJSON() ([]byte, error)
func (*ExtendedProviderInfo) UnmarshalJSON ¶
func (p *ExtendedProviderInfo) UnmarshalJSON(data []byte) error
type ExtendedProviders ¶
type ExtendedProviders struct { // Providers contains a chain-level set of extended providers. Providers []ExtendedProviderInfo `json:",omitempty"` // ContextualProviders contains a context-level sets of extended providers. ContextualProviders map[string]ContextualExtendedProviders `json:",omitempty"` }
ExtendedProviders contains chain-level and context-level extended provider sets.
type Option ¶ added in v0.5.5
type Option func(*regConfig) error
Option is a function that sets a value in a regConfig.
func WithFreezer ¶ added in v0.5.5
type ProviderInfo ¶
type ProviderInfo struct { // AddrInfo contains a peer.ID and set of Multiaddr addresses. AddrInfo peer.AddrInfo // LastAdvertisement identifies the latest advertisement the indexer has ingested. LastAdvertisement cid.Cid `json:",omitempty"` // LastAdvertisementTime is the time the latest advertisement was received. LastAdvertisementTime time.Time // Lag is how far the indexer is behing in processing the ad chain. Lag int `json:",omitempty"` // Publisher contains the ID of the provider info publisher. Publisher peer.ID `json:",omitempty"` // PublisherAddr contains the last seen publisher multiaddr. PublisherAddr multiaddr.Multiaddr `json:",omitempty"` // ExtendedProviders registered for that provider ExtendedProviders *ExtendedProviders `json:",omitempty"` // FrozenAt identifies the last advertisement that was received before the // indexer became frozen. FrozenAt cid.Cid `json:",omitempty"` // FrozenAtTime is the time that the FrozenAt advertisement was received. FrozenAtTime time.Time // LastError is a description of the last ingestion error to occur for this // provider. LastError string `json:",omitempty"` // LastErrorTime is the time that LastError occurred. LastErrorTime time.Time // contains filtered or unexported fields }
ProviderInfo is an immutable data structure that holds information about a provider. A ProviderInfo instance is never modified, but rather a new one is created to update its contents. This means existing references remain valid.
func (*ProviderInfo) Deleted ¶
func (p *ProviderInfo) Deleted() bool
func (*ProviderInfo) Inactive ¶
func (p *ProviderInfo) Inactive() bool
func (*ProviderInfo) MarshalJSON ¶
func (p *ProviderInfo) MarshalJSON() ([]byte, error)
func (*ProviderInfo) StopCid ¶ added in v0.5.5
func (p *ProviderInfo) StopCid() cid.Cid
StopCid returns the CID of the advertisement to stop at when handling handoff from another indexer that is frozen.
func (*ProviderInfo) UnmarshalJSON ¶
func (p *ProviderInfo) UnmarshalJSON(data []byte) error
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores information about discovered providers
func New ¶ added in v0.5.5
func New(ctx context.Context, cfg config.Discovery, dstore datastore.Datastore, options ...Option) (*Registry, error)
New creates a new provider registry, giving it provider policy configuration, a datastore to persist provider data. The context is only used for cancellation of this function.
func (*Registry) AllProviderInfo ¶
func (r *Registry) AllProviderInfo() []*ProviderInfo
AllProviderInfo returns information for all registered providers that are active and allowed.
func (*Registry) AllowPeer ¶
AllowPeer configures the policy to allow messages published by the identified peer. Returns true if policy changed. This configuration is not persisted across indexer restarts. Update the indexer config file to persist the change.
func (*Registry) Allowed ¶
Allowed checks if the peer is allowed by policy. If configured to work with an assigner service, then the peer must also be assigned to the indexer to be allowed.
func (*Registry) AssignPeer ¶
AssignPeer assigns the peer to this indexer if using an assigner service. This allows the indexer to accept announce messages having this peer as a publisher. The assignment is persisted in the datastore.
func (*Registry) BlockPeer ¶
BlockPeer configures the policy to block messages published by the identified peer. Returns true if policy changed. This configuration is not persisted across indexer restarts. Update the indexer config file to persist the change.
func (*Registry) Close ¶
func (r *Registry) Close()
Close stops the registry and waits for polling to finish.
func (*Registry) FilterIPsEnabled ¶
FilterIPsEnabled returns true if IP address filtering is enabled.
func (*Registry) Freeze ¶ added in v0.5.5
Freeze puts the indexer into forzen mode.
The registry in not frozen directly, but the Freezer is triggered instead.
func (*Registry) ImportProviders ¶
ImportProviders reads providers from another indexer and registers any that are not already registered. Returns the count of newly registered providers.
func (*Registry) IsRegistered ¶
IsRegistered checks if the provider is in the registry
func (*Registry) ListAssignedPeers ¶
ListAssignedPeers returns list of assigned peer IDs, when the indexer is configured to work with an assigner service. Otherwise returns error.
func (*Registry) ListPreferredPeers ¶
ListPreferredPeers returns list of unassigned peer IDs, that the indexer has already retrieved advertisements from. Only available when the indexer is configured to work with an assigner service. Otherwise returns error.
func (*Registry) ProviderInfo ¶
func (r *Registry) ProviderInfo(providerID peer.ID) (*ProviderInfo, bool)
ProviderInfo returns information for a registered provider.
func (*Registry) PublishAllowed ¶
PublishAllowed checks if a peer is allowed to publish for other providers.
func (*Registry) RemoveProvider ¶
func (*Registry) SetLastError ¶ added in v0.7.4
func (*Registry) SetMaxPoll ¶ added in v0.8.3
SetMaxPoll sets the maximum number of providers to poll at each polling retry.
func (*Registry) SyncChan ¶
func (r *Registry) SyncChan() <-chan *ProviderInfo
func (*Registry) UnassignPeer ¶
UnassignPeer removes a peer assignment from this indexer if using an assigner service. The assignment removal is persisted in the datastore. Returns true if the specified peer was assigned.
func (*Registry) Update ¶
func (r *Registry) Update(ctx context.Context, provider, publisher peer.AddrInfo, adCid cid.Cid, extendedProviders *ExtendedProviders, lag int) error
Update attempts to update the registry's provider information. If publisher has a valid ID, then the supplied publisher data replaces the provider's previous publisher information.
func (*Registry) ValueStoreUsage ¶ added in v0.5.5
func (r *Registry) ValueStoreUsage() (*disk.UsageStats, error)