Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
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_privtrak_gc_duration_milliseconds", Help: "The time it takes to perform privtrak garbage collection", Buckets: prometheus.ExponentialBuckets(9.375, 2, 10), }) // PromUsersCount is a gauge used to hold the current total amount of // unique swarms being tracked by a storage. PromUsersCount = prometheus.NewGauge(prometheus.GaugeOpts{ Name: "chihaya_privtrak_users_count", Help: "The number of users tracked", }) )
View Source
var ErrClosing = errors.New("privtrak middleware closing")
ErrClosing is returned on an announce if the middleware is shut down.
Functions ¶
func New ¶
func New(provided Config, identifier UserIdentifier, handler DeltaHandler) (middleware.Hook, error)
New constructs a new instance of the privtrak middleware.
Types ¶
type Config ¶
type Config struct { BatchSize uint `yaml:"batch_size"` ShardCount uint `yaml:"shard_count"` GCInterval time.Duration `yaml:"gc_interval"` PrometheusReportingInterval time.Duration `yaml:"prometheus_reporting_interval"` PeerLifetime time.Duration `yaml:"peer_lifetime"` }
A Config holds the configuration for the privtrak middleware.
type DeltaHandler ¶
type DeltaHandler interface { // HandleDeltas handles a batch of deltas. // This operation is assumed to be atomic: // if no error is returned, the deltas are assumed to be persisted and // thus deleted from this middleware // if an error is returned, the deltas are kept in the middleware and the // error will be returned on the announce route. We will attempt to // flush the deltas again next time, or during routine garbage // collection. HandleDeltas([]StatDelta) error }
A DeltaHandler handles batches of stat-deltas.
type StatDelta ¶
type StatDelta struct { User ID InfoHash bittorrent.InfoHash DeltaUp int64 DeltaDown int64 Event bittorrent.Event Reported time.Time }
A StatDelta is a delta for a user's stats. It contains the infohash, the event the client provided with the announce and a timestamp.
type UserIdentifier ¶
type UserIdentifier interface {
DeriveID(*bittorrent.AnnounceRequest) (ID, error)
}
A UserIdentifier identifies an ID from a request.
Click to show internal directories.
Click to hide internal directories.