Documentation ¶
Index ¶
- Variables
- func AnnounceLeecher(b *testing.B, ps PeerStore)
- func AnnounceLeecher1kInfohash(b *testing.B, ps PeerStore)
- func AnnounceSeeder(b *testing.B, ps PeerStore)
- func AnnounceSeeder1kInfohash(b *testing.B, ps PeerStore)
- func DeleteNonexist(b *testing.B, ps PeerStore)
- func DeleteNonexist1k(b *testing.B, ps PeerStore)
- func DeleteNonexist1kInfohash(b *testing.B, ps PeerStore)
- func DeleteNonexist1kInfohash1k(b *testing.B, ps PeerStore)
- func GradNonexist(b *testing.B, ps PeerStore)
- func GradNonexist1k(b *testing.B, ps PeerStore)
- func GradNonexist1kInfohash(b *testing.B, ps PeerStore)
- func GradNonexist1kInfohash1k(b *testing.B, ps PeerStore)
- func Put(b *testing.B, ps PeerStore)
- func Put1k(b *testing.B, ps PeerStore)
- func Put1kInfohash(b *testing.B, ps PeerStore)
- func Put1kInfohash1k(b *testing.B, ps PeerStore)
- func PutDelete(b *testing.B, ps PeerStore)
- func PutDelete1k(b *testing.B, ps PeerStore)
- func PutDelete1kInfohash(b *testing.B, ps PeerStore)
- func PutDelete1kInfohash1k(b *testing.B, ps PeerStore)
- func PutGradDelete(b *testing.B, ps PeerStore)
- func PutGradDelete1k(b *testing.B, ps PeerStore)
- func PutGradDelete1kInfohash(b *testing.B, ps PeerStore)
- func PutGradDelete1kInfohash1k(b *testing.B, ps PeerStore)
- func RegisterDriver(name string, d Driver)
- func TestPeerStore(t *testing.T, p PeerStore)
- type Driver
- type PeerStore
Constants ¶
This section is empty.
Variables ¶
var ( // PromGCDurationMilliseconds is a histogram used by storage to record the // durations of execution time required for removing expired peers. PromGCDurationMilliseconds = prometheus.NewHistogram(prometheus.HistogramOpts{ Name: "chihaya_storage_gc_duration_milliseconds", Help: "The time it takes to perform storage garbage collection", Buckets: prometheus.ExponentialBuckets(9.375, 2, 10), }) // PromInfohashesCount is a gauge used to hold the current total amount of // unique swarms being tracked by a storage. PromInfohashesCount = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "chihaya_storage_infohashes_count", Help: "The number of Infohashes tracked", }) // PromSeedersCount is a gauge used to hold the current total amount of // unique seeders per swarm. PromSeedersCount = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "chihaya_storage_seeders_count", Help: "The number of seeders tracked", }) // PromLeechersCount is a gauge used to hold the current total amount of // unique leechers per swarm. PromLeechersCount = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "chihaya_storage_leechers_count", Help: "The number of leechers tracked", }) )
var ErrDriverDoesNotExist = errors.New("peer store driver with that name does not exist")
ErrDriverDoesNotExist is the error returned by NewPeerStore when a peer store driver with that name does not exist.
var ErrResourceDoesNotExist = bittorrent.ClientError("resource does not exist")
ErrResourceDoesNotExist is the error returned by all delete methods in the store if the requested resource does not exist.
var PeerEqualityFunc = func(p1, p2 bittorrent.Peer) bool { return p1.Equal(p2) }
PeerEqualityFunc is the boolean function to use to check two Peers for equality.
Functions ¶
func AnnounceLeecher ¶
AnnounceLeecher benchmarks the AnnouncePeers method of a PeerStore for announcing a leecher. The swarm announced to has 500 seeders and 500 leechers.
AnnounceLeecher can run in parallel.
func AnnounceLeecher1kInfohash ¶
AnnounceLeecher1kInfohash behaves like AnnounceLeecher with one of 1000 infohashes.
AnnounceLeecher1kInfohash can run in parallel.
func AnnounceSeeder ¶
AnnounceSeeder behaves like AnnounceLeecher with a seeder instead of a leecher.
AnnounceSeeder can run in parallel.
func AnnounceSeeder1kInfohash ¶
AnnounceSeeder1kInfohash behaves like AnnounceSeeder with one of 1000 infohashes.
AnnounceSeeder1kInfohash can run in parallel.
func DeleteNonexist ¶
DeleteNonexist benchmarks the DeleteSeeder method of a PeerStore by attempting to delete a Peer that is nonexistent.
DeleteNonexist can run in parallel.
func DeleteNonexist1k ¶
DeleteNonexist1k benchmarks the DeleteSeeder method of a PeerStore by attempting to delete one of 1000 nonexistent Peers.
DeleteNonexist can run in parallel.
func DeleteNonexist1kInfohash ¶
DeleteNonexist1kInfohash benchmarks the DeleteSeeder method of a PeerStore by attempting to delete one Peer from one of 1000 infohashes.
DeleteNonexist1kInfohash can run in parallel.
func DeleteNonexist1kInfohash1k ¶
DeleteNonexist1kInfohash1k benchmarks the Delete method of a PeerStore by attempting to delete one of 1000 Peers from one of 1000 Infohashes.
DeleteNonexist1kInfohash1k can run in parallel.
func GradNonexist ¶
GradNonexist benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate a nonexistent Peer.
GradNonexist can run in parallel.
func GradNonexist1k ¶
GradNonexist1k benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate one of 1000 nonexistent Peers.
GradNonexist1k can run in parallel.
func GradNonexist1kInfohash ¶
GradNonexist1kInfohash benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate a nonexistent Peer for one of 100 Infohashes.
GradNonexist1kInfohash can run in parallel.
func GradNonexist1kInfohash1k ¶
GradNonexist1kInfohash1k benchmarks the GraduateLeecher method of a PeerStore by attempting to graduate one of 1000 nonexistent Peers for one of 1000 infohashes.
GradNonexist1kInfohash1k can run in parallel.
func Put ¶
Put benchmarks the PutSeeder method of a PeerStore by repeatedly Putting the same Peer for the same InfoHash.
Put can run in parallel.
func Put1k ¶
Put1k benchmarks the PutSeeder method of a PeerStore by cycling through 1000 Peers and Putting them into the swarm of one infohash.
Put1k can run in parallel.
func Put1kInfohash ¶
Put1kInfohash benchmarks the PutSeeder method of a PeerStore by cycling through 1000 infohashes and putting the same peer into their swarms.
Put1kInfohash can run in parallel.
func Put1kInfohash1k ¶
Put1kInfohash1k benchmarks the PutSeeder method of a PeerStore by cycling through 1000 infohashes and 1000 Peers and calling Put with them.
Put1kInfohash1k can run in parallel.
func PutDelete ¶
PutDelete benchmarks the PutSeeder and DeleteSeeder methods of a PeerStore by calling PutSeeder followed by DeleteSeeder for one Peer and one infohash.
PutDelete can not run in parallel.
func PutDelete1k ¶
PutDelete1k benchmarks the PutSeeder and DeleteSeeder methods in the same way PutDelete does, but with one from 1000 Peers per iteration.
PutDelete1k can not run in parallel.
func PutDelete1kInfohash ¶
PutDelete1kInfohash behaves like PutDelete1k with 1000 infohashes instead of 1000 Peers.
PutDelete1kInfohash can not run in parallel.
func PutDelete1kInfohash1k ¶
PutDelete1kInfohash1k behaves like PutDelete1k with 1000 infohashes in addition to 1000 Peers.
PutDelete1kInfohash1k can not run in parallel.
func PutGradDelete ¶
PutGradDelete benchmarks the PutLeecher, GraduateLeecher and DeleteSeeder methods of a PeerStore by adding one leecher to a swarm, promoting it to a seeder and deleting the seeder.
PutGradDelete can not run in parallel.
func PutGradDelete1k ¶
PutGradDelete1k behaves like PutGradDelete with one of 1000 Peers.
PutGradDelete1k can not run in parallel.
func PutGradDelete1kInfohash ¶
PutGradDelete1kInfohash behaves like PutGradDelete with one of 1000 infohashes.
PutGradDelete1kInfohash can not run in parallel.
func PutGradDelete1kInfohash1k ¶
PutGradDelete1kInfohash1k behaves like PutGradDelete with one of 1000 Peers and one of 1000 infohashes.
PutGradDelete1kInfohash can not run in parallel.
func RegisterDriver ¶
RegisterDriver makes a Driver available by the provided name.
If called twice with the same name, the name is blank, or if the provided Driver is nil, this function panics.
func TestPeerStore ¶
TestPeerStore tests a PeerStore implementation against the interface.
Types ¶
type PeerStore ¶
type PeerStore interface { // PutSeeder adds a Seeder to the Swarm identified by the provided // infoHash. PutSeeder(infoHash bittorrent.InfoHash, p bittorrent.Peer) error // DeleteSeeder removes a Seeder from the Swarm identified by the // provided infoHash. // // If the Swarm or Peer does not exist, this function should return // ErrResourceDoesNotExist. DeleteSeeder(infoHash bittorrent.InfoHash, p bittorrent.Peer) error // PutLeecher adds a Leecher to the Swarm identified by the provided // infoHash. PutLeecher(infoHash bittorrent.InfoHash, p bittorrent.Peer) error // DeleteLeecher removes a Leecher from the Swarm identified by the // provided infoHash. // // If the Swarm or Peer does not exist, this function should return // ErrResourceDoesNotExist. DeleteLeecher(infoHash bittorrent.InfoHash, p bittorrent.Peer) error // GraduateLeecher promotes a Leecher to a Seeder in the Swarm // identified by the provided infoHash. // // If the given Peer is not present as a Leecher, add the Peer as a // Seeder and return no error. GraduateLeecher(infoHash bittorrent.InfoHash, p bittorrent.Peer) error // AnnouncePeers is a best effort attempt to return Peers from the Swarm // identified by the provided infoHash. The returned Peers are required // to be either all IPv4 or all IPv6. // // The returned Peers should strive be: // - as close to length equal to numWant as possible without going over // - all IPv4 or all IPv6 depending on the provided peer // - if seeder is true, should ideally return more leechers than seeders // - if seeder is false, should ideally return more seeders than // leechers // // Returns ErrResourceDoesNotExist if the provided infoHash is not tracked. AnnouncePeers(infoHash bittorrent.InfoHash, seeder bool, numWant int, p bittorrent.Peer) (peers []bittorrent.Peer, err error) // ScrapeSwarm returns information required to answer a scrape request // about a swarm identified by the given infohash. // The AddressFamily indicates whether or not the IPv6 swarm should be // scraped. // The Complete and Incomplete fields of the Scrape must be filled, // filling the Snatches field is optional. // If the infohash is unknown to the PeerStore, an empty Scrape is // returned. ScrapeSwarm(infoHash bittorrent.InfoHash, addressFamily bittorrent.AddressFamily) bittorrent.Scrape // stop is an interface that expects a Stop method to stop the // PeerStore. // For more details see the documentation in the stop package. stop.Stopper // LogFields returns a loggable version of the data used to configure and // operate a particular peer store. LogFields() log.Fields }
PeerStore is an interface that abstracts the interactions of storing and manipulating Peers such that it can be implemented for various data stores.
func NewPeerStore ¶
NewPeerStore attempts to initialize a new PeerStore with given a name from the list of registered Drivers.
If a driver does not exist, returns ErrDriverDoesNotExist.
Directories ¶
Path | Synopsis |
---|---|
Package memory implements the storage interface for a Chihaya BitTorrent tracker keeping peer data in memory.
|
Package memory implements the storage interface for a Chihaya BitTorrent tracker keeping peer data in memory. |
Package memorybysubnet implements the storage interface for a Chihaya BitTorrent tracker keeping peer data in memory organized by a pre-configured subnet mask.
|
Package memorybysubnet implements the storage interface for a Chihaya BitTorrent tracker keeping peer data in memory organized by a pre-configured subnet mask. |