ddbps

package module
v0.0.0-...-a97f9d5 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: MIT Imports: 12 Imported by: 0

README

This is a ProviderStore that stores DHT records in DynamoDB.

The schema of the table is:

  • key (bytes)
    • Primary Key
    • typically this is the raw multihash of a CID
  • ttl (number)
    • Sort Key
    • unix epoch timestamp of when the entry expires
    • configure your DynamoDB table to use this as an item TTL for auto-eviction
    • since this is a sort key, results for a given CID are ordered by this, so that you can return the most recently-cached providers first
  • prov (bytes)
    • the raw peer ID of the provider of the given key

A DHT put maps to a single PutItem request to DynamoDB.

DHT queries map to a DynamoDB Query, keyed on the CID multihash. The query returns an item per provider of the CID, up to a pre-configured limit. For popular CIDs with many providers, this could take many round-trips to DynamoDB to finish. A single round-trip can return up to 1 MB of items. Since items are automatically evicted by DynamoDB based on their TTL, this automatically excludes expired entries.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DynamoDBProviderStore

type DynamoDBProviderStore struct {
	Self       peer.ID
	PeerStore  peerStore
	DDBClient  *dynamodb.Client
	TableName  string
	TTL        time.Duration
	QueryLimit int32
}

func (*DynamoDBProviderStore) AddProvider

func (d *DynamoDBProviderStore) AddProvider(ctx context.Context, key []byte, prov peer.AddrInfo) error

func (*DynamoDBProviderStore) GetProviders

func (d *DynamoDBProviderStore) GetProviders(ctx context.Context, key []byte) ([]peer.AddrInfo, error)

Jump to

Keyboard shortcuts

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