counter

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IndexCounts

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

IndexCounts persists multihash counts associated with provider ContextIDs. It is not safe to allow concurrent calls to IndexCounts methods for the same provider. Concurrent calls for different providers are safe.

func NewIndexCounts

func NewIndexCounts(ds datastore.Datastore) *IndexCounts

NewIndexCounts creates a new IndexCounts given a Datastore.

func (*IndexCounts) AddCount

func (c *IndexCounts) AddCount(providerID peer.ID, contextID []byte, count uint64)

AddCount adds the index count to the existing count for the provider's context ID, and updates in-memory totals.

func (*IndexCounts) AddMissingCount

func (c *IndexCounts) AddMissingCount(providerID peer.ID, contextID []byte, count uint64)

AddMissingCount stores the count only if there is no existing count for the provider's context ID, and updates in-memory totals.

func (*IndexCounts) Provider

func (c *IndexCounts) Provider(providerID peer.ID) (uint64, error)

Provider reads all index counts for a provider.

func (*IndexCounts) RemoveCtx

func (c *IndexCounts) RemoveCtx(providerID peer.ID, contextID []byte) (uint64, error)

RemoveCtx removes the index count for a provider's contextID.

func (*IndexCounts) RemoveProvider

func (c *IndexCounts) RemoveProvider(providerID peer.ID) uint64

RemoveProvider removes all index counts for a provider.

func (*IndexCounts) SetTotalAddend

func (c *IndexCounts) SetTotalAddend(totalAddend uint64)

SetTotalAddent sets a value that is added to the index count returned by Total. Its purpose is to account for uncounted indexes that have existed since before provider index counts were tracked. This only affects Total, and does not affect any individual provider values.

func (*IndexCounts) Total

func (c *IndexCounts) Total() (uint64, error)

Total returns the total of all index counts for all providers.

Jump to

Keyboard shortcuts

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