redis

package
v0.0.0-...-384af84 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2023 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package redis implements the storage interface for a Chihaya BitTorrent tracker keeping peer data in redis with hash. There two categories of hash:

  • IPv{4,6}_{L,S}_infohash To save peers that hold the infohash, used for fast searching, deleting, and timeout handling

  • IPv{4,6} To save all the infohashes, used for garbage collection, metrics aggregation and leecher graduation

Tree keys are used to record the count of swarms, seeders and leechers for each group (IPv4, IPv6).

  • IPv{4,6}_infohash_count To record the number of infohashes.

  • IPv{4,6}_S_count To record the number of seeders.

  • IPv{4,6}_L_count To record the number of leechers.

Index

Constants

View Source
const Name = "redis"

Name is the name by which this peer store is registered with Chihaya.

Variables

This section is empty.

Functions

func New

func New(provided Config) (storage.PeerStore, error)

New creates a new PeerStore backed by redis.

Types

type Config

type Config struct {
	GarbageCollectionInterval   time.Duration `yaml:"gc_interval"`
	PrometheusReportingInterval time.Duration `yaml:"prometheus_reporting_interval"`
	PeerLifetime                time.Duration `yaml:"peer_lifetime"`
	RedisBroker                 string        `yaml:"redis_broker"`
	RedisReadTimeout            time.Duration `yaml:"redis_read_timeout"`
	RedisWriteTimeout           time.Duration `yaml:"redis_write_timeout"`
	RedisConnectTimeout         time.Duration `yaml:"redis_connect_timeout"`
}

Config holds the configuration of a redis PeerStore.

func (Config) LogFields

func (cfg Config) LogFields() log.Fields

LogFields renders the current config as a set of Logrus fields.

func (Config) Validate

func (cfg Config) Validate() Config

Validate sanity checks values set in a config and returns a new config with default values replacing anything that is invalid.

This function warns to the logger when a value is changed.

Jump to

Keyboard shortcuts

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