Documentation ¶
Index ¶
- type MySQLStore
- func (m *MySQLStore) GetTorrent(infoHash string) (*schemas.Torrent, error)
- func (m *MySQLStore) GetWhitelistedTorrent(infoHash string) (*schemas.WhiteTorrent, error)
- func (m *MySQLStore) GetWhitelistedTorrents() (*sql.Rows, error)
- func (m *MySQLStore) HandlePeerUpdates() chan PeerTrackerDelta
- func (m *MySQLStore) OpenConnection() (*gorm.DB, error)
- func (m *MySQLStore) ScrapeTorrent(infoHash string) *schemas.Torrent
- func (m *MySQLStore) UpdatePeerStats(uploaded uint64, downloaded uint64, ip string)
- func (m *MySQLStore) UpdateStats(uploaded uint64, downloaded uint64)
- func (m *MySQLStore) UpdateTorrentStats(uploaded int64, downloaded int64)
- type PeerDeltaEvent
- type PeerTrackerDelta
- type PostgresStore
- func (m *PostgresStore) GetTorrent(infoHash string) (*schemas.Torrent, error)
- func (m *PostgresStore) GetWhitelistedTorrent(infoHash string) (*schemas.WhiteTorrent, error)
- func (m *PostgresStore) GetWhitelistedTorrents() (*sql.Rows, error)
- func (m *PostgresStore) HandlePeerUpdates() chan PeerTrackerDelta
- func (m *PostgresStore) OpenConnection() (*gorm.DB, error)
- func (m *PostgresStore) ScrapeTorrent(infoHash string) *schemas.Torrent
- func (m *PostgresStore) UpdatePeerStats(uploaded uint64, downloaded uint64, ip string)
- func (m *PostgresStore) UpdateStats(uploaded uint64, downloaded uint64)
- func (m *PostgresStore) UpdateTorrentStats(uploaded int64, downloaded int64)
- type SQLStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MySQLStore ¶
type MySQLStore struct { UpdateConsumer chan PeerTrackerDelta // contains filtered or unexported fields }
MySQLStore represents the mysql implementation of `SQLStore`
func InitMySQLStore ¶
func InitMySQLStore() (store MySQLStore)
InitMySQLStore Creates a `MySQLStore` object and initiates all necessary moving parts like the `HandlePeerUpdates` channel consumer.
func (*MySQLStore) GetTorrent ¶
func (m *MySQLStore) GetTorrent(infoHash string) (*schemas.Torrent, error)
GetTorrent wraps `mysql.GetTorrent`.
func (*MySQLStore) GetWhitelistedTorrent ¶
func (m *MySQLStore) GetWhitelistedTorrent(infoHash string) (*schemas.WhiteTorrent, error)
GetWhitelistedTorrent wraps `mysql.GetWhitelistedTorrent`.
func (*MySQLStore) GetWhitelistedTorrents ¶
func (m *MySQLStore) GetWhitelistedTorrents() (*sql.Rows, error)
GetWhitelistedTorrents wraps `mysql.GetWhitelistedTorrents`.
func (*MySQLStore) HandlePeerUpdates ¶
func (m *MySQLStore) HandlePeerUpdates() chan PeerTrackerDelta
HandlePeerUpdates handles listening and aggregating peer updates. THis allows block/asynchronous consumption of peer updates, rather than updating the remote database at the end of every request.
func (*MySQLStore) OpenConnection ¶
func (m *MySQLStore) OpenConnection() (*gorm.DB, error)
OpenConnection wraps `mysql.OpenConnection`.
func (*MySQLStore) ScrapeTorrent ¶
func (m *MySQLStore) ScrapeTorrent(infoHash string) *schemas.Torrent
ScrapeTorrent wraps `mysql.ScrapeTorrent`.
func (*MySQLStore) UpdatePeerStats ¶
func (m *MySQLStore) UpdatePeerStats(uploaded uint64, downloaded uint64, ip string)
UpdatePeerStats wraps `mysql.UpdatePeerStats`.
func (*MySQLStore) UpdateStats ¶
func (m *MySQLStore) UpdateStats(uploaded uint64, downloaded uint64)
UpdateStats wraps `mysql.UpdateStats`.
func (*MySQLStore) UpdateTorrentStats ¶
func (m *MySQLStore) UpdateTorrentStats(uploaded int64, downloaded int64)
UpdateTorrentStats wraps `mysql.UpdateTorrentStats`.
type PeerDeltaEvent ¶
type PeerDeltaEvent int
PeerDeltaEvent allows us to set an event to handle how we're going to update teh database.
const ( // PEERUPDATE represents a change to a peer, so we'll update a tracker // user's ratio. PEERUPDATE PeerDeltaEvent = iota // TRACKERUPDATE handles updating total tracker stats TRACKERUPDATE // TORRENTUPDATE represents the changes to a specific torrent where we // update total upload/download for the torrent itself. TORRENTUPDATE )
type PeerTrackerDelta ¶
type PeerTrackerDelta struct { Uploaded uint64 Downloaded uint64 IP string Event PeerDeltaEvent }
PeerTrackerDelta handles holding data to be updated by the `UpdateConsumer`.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
func InitPostgresStore ¶
func InitPostgresStore() (store PostgresStore)
InitPostgresStore Creates a `PostgresStore` object and initiates all necessary moving parts like the `HandlePeerUpdates` channel consumer.
func (*PostgresStore) GetTorrent ¶
func (m *PostgresStore) GetTorrent(infoHash string) (*schemas.Torrent, error)
GetTorrent wraps `postgres.GetTorrent`.
func (*PostgresStore) GetWhitelistedTorrent ¶
func (m *PostgresStore) GetWhitelistedTorrent(infoHash string) (*schemas.WhiteTorrent, error)
GetWhitelistedTorrent wraps `postgres.GetWhitelistedTorrent`.
func (*PostgresStore) GetWhitelistedTorrents ¶
func (m *PostgresStore) GetWhitelistedTorrents() (*sql.Rows, error)
GetWhitelistedTorrents wraps `postgres.GetWhitelistedTorrents`.
func (*PostgresStore) HandlePeerUpdates ¶
func (m *PostgresStore) HandlePeerUpdates() chan PeerTrackerDelta
HandlePeerUpdates handles listening and aggregating peer updates. THis allows block/asynchronous consumption of peer updates, rather than updating the remote database at the end of every request.
func (*PostgresStore) OpenConnection ¶
func (m *PostgresStore) OpenConnection() (*gorm.DB, error)
OpenConnection wraps `postgres.OpenConnection`.
func (*PostgresStore) ScrapeTorrent ¶
func (m *PostgresStore) ScrapeTorrent(infoHash string) *schemas.Torrent
ScrapeTorrent wraps `postgres.ScrapeTorrent`.
func (*PostgresStore) UpdatePeerStats ¶
func (m *PostgresStore) UpdatePeerStats(uploaded uint64, downloaded uint64, ip string)
UpdatePeerStats wraps `postgres.UpdatePeerStats`.
func (*PostgresStore) UpdateStats ¶
func (m *PostgresStore) UpdateStats(uploaded uint64, downloaded uint64)
UpdateStats wraps `postgres.UpdateStats`.
func (*PostgresStore) UpdateTorrentStats ¶
func (m *PostgresStore) UpdateTorrentStats(uploaded int64, downloaded int64)
UpdateTorrentStats wraps `postgres.UpdateTorrentStats`.
type SQLStore ¶
type SQLStore interface { OpenConnection() (*gorm.DB, error) GetTorrent(string) (*schemas.Torrent, error) GetWhitelistedTorrent(string) (*schemas.WhiteTorrent, error) UpdateStats(uint64, uint64) UpdateTorrentStats(int64, int64) ScrapeTorrent(string) *schemas.Torrent GetWhitelistedTorrents() (*sql.Rows, error) UpdatePeerStats(uint64, uint64, string) HandlePeerUpdates() chan PeerTrackerDelta }
SQLStore is the base implementation for a database which will be used to store stats and retrieve whitelisted torrents.
func InitSQLStoreByDBChoice ¶
func InitSQLStoreByDBChoice() SQLStore