storage

package
v0.0.0-...-1335a43 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2013 License: BSD-2-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package storage provides a generic interface for manipulating a BitTorrent tracker's web application data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(name string, driver Driver)

Register makes a database driver available by the provided name. If Register is called twice with the same name or if driver is nil, it panics.

Types

type AnnounceDelta

type AnnounceDelta struct {
	Peer    *models.Peer
	Torrent *models.Torrent
	User    *models.User

	// Created is true if this announce created a new peer or changed an existing peer's address
	Created bool

	// Uploaded contains the raw upload delta for this announce, in bytes
	Uploaded uint64

	// Downloaded contains the raw download delta for this announce, in bytes
	Downloaded uint64

	// Timestamp is the unix timestamp this announce occurred at
	Timestamp float64

	// Snatched is true if this announce completed the download
	Snatched bool
}

AnnounceDelta contains a difference in statistics for a peer. It is used for communicating changes to be recorded by the storage driver.

type Conn

type Conn interface {
	// Start is called once when the server starts.
	// It starts any necessary goroutines a given driver requires, and sets
	// up the driver's initial state
	Start() error

	// Close terminates connections to the database(s) and gracefully shuts
	// down the driver
	Close() error

	// RecordAnnounce is called once per announce, and is passed the delta in
	// statistics for the client peer since its last announce.
	RecordAnnounce(delta *AnnounceDelta) error

	// LoadTorrents fetches and returns the specified torrents.
	LoadTorrents(ids []uint64) ([]*models.Torrent, error)

	// LoadAllTorrents fetches and returns all torrents.
	LoadAllTorrents() ([]*models.Torrent, error)

	// LoadUsers fetches and returns the specified users.
	LoadUsers(ids []uint64) ([]*models.User, error)

	// LoadAllUsers fetches and returns all users.
	LoadAllUsers(ids []uint64) ([]*models.User, error)
}

Conn represents a connection to the data store.

func Open

func Open(conf *config.DataStore) (Conn, error)

Open creates a connection specified by a storage configuration.

type Driver

type Driver interface {
	New(*config.DataStore) Conn
}

Directories

Path Synopsis
Package batter provides a driver for a BitTorrent tracker to interface with the postgres database used by batter (github.com/wafflesfm/batter).
Package batter provides a driver for a BitTorrent tracker to interface with the postgres database used by batter (github.com/wafflesfm/batter).
Package gazelle provides a driver for a BitTorrent tracker to interface with the MySQL database used by Gazelle (github.com/WhatCD/Gazelle).
Package gazelle provides a driver for a BitTorrent tracker to interface with the MySQL database used by Gazelle (github.com/WhatCD/Gazelle).

Jump to

Keyboard shortcuts

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