postgres

package
v0.0.0-...-640c710 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2017 License: MIT Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTorrent

func GetTorrent(dbConn *gorm.DB, infoHash string) (t *schemas.Torrent, err error)

GetTorrent retrieves a torrent by its infoHash from the generic torrent table in the database. Note: there's also a whitelisted torrent table (`WhiteTorrent`).

func GetWhitelistedTorrent

func GetWhitelistedTorrent(dbConn *gorm.DB, infoHash string) (t *schemas.WhiteTorrent, err error)

GetWhitelistedTorrent Retrieves a single whitelisted torrent by its infoHash

func GetWhitelistedTorrents

func GetWhitelistedTorrents(dbConn *gorm.DB) (x *sql.Rows, err error)

GetWhitelistedTorrents allows us to retrieve all of the white listed torrents. Mostly used for populating the Redis KV storage with all of our whitelisted torrents.

func InitDB

func InitDB(dbConn *gorm.DB)

InitDB initializes database tables.

func OpenConnection

func OpenConnection() (db *gorm.DB, err error)

OpenConnection does as its name dictates and opens a connection to the PostgresHost listed in the config

func OpenConnectionWithConfig

func OpenConnectionWithConfig(cfg *config.ConfigStruct) (db *gorm.DB, err error)

OpenConnectionWithConfig handles `OpenConnection` but allows injecting a config file.

func ScrapeTorrent

func ScrapeTorrent(dbConn *gorm.DB, infoHash string) (torrent *schemas.Torrent)

ScrapeTorrent supports the Scrape convention

func UpdatePeerStats

func UpdatePeerStats(dbConn *gorm.DB, uploaded uint64, downloaded uint64, ip string)

UpdatePeerStats handles updating peer info like hits per ip, downloaded amount, uploaded amounts.

func UpdateStats

func UpdateStats(dbConn *gorm.DB, uploaded uint64, downloaded uint64)

UpdateStats Handles updating statistics relevant to our tracker.

func UpdateTorrentStats

func UpdateTorrentStats(dbConn *gorm.DB, seederDelta int64, leecherDelta int64)

UpdateTorrentStats Handles updating statistics relevant to our tracker.

Types

type PGListener

type PGListener struct {
	// contains filtered or unexported fields
}

func NewListener

func NewListener(c config.ConfigStruct) (*PGListener, error)

func (*PGListener) BeginListen

func (pg *PGListener) BeginListen(callback callbackFunction)

DO we want a callback or something else?

Jump to

Keyboard shortcuts

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