Embed *db.Sql into storage/gazelle
This commit is contained in:
parent
afa8abb9ab
commit
46280fd97b
3 changed files with 6 additions and 5 deletions
|
@ -14,7 +14,7 @@ import (
|
|||
"github.com/pushrax/chihaya/config"
|
||||
|
||||
_ "github.com/pushrax/chihaya/cache/redis"
|
||||
_ "github.com/pushrax/chihaya/storage/batter"
|
||||
_ "github.com/pushrax/chihaya/storage/gazelle"
|
||||
)
|
||||
|
||||
func newTestServer() (*Server, error) {
|
||||
|
|
|
@ -43,7 +43,7 @@ func (c *Conn) flushTorrents() {
|
|||
"Seeders = VALUES(Seeders), Leechers = VALUES(Leechers), " +
|
||||
"last_action = IF(last_action < VALUES(last_action), VALUES(last_action), last_action);")
|
||||
|
||||
c.db.Exec(query.String())
|
||||
c.Exec(query.String())
|
||||
|
||||
if length < cap(c.torrentChannel)/2 {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
|
|
@ -35,7 +35,7 @@ func (d *driver) New(conf *config.DataStore) storage.Conn {
|
|||
}
|
||||
db.SetMaxIdleConns(conf.MaxIdleConns)
|
||||
|
||||
conn := &Conn{db: db}
|
||||
conn := &Conn{DB: db}
|
||||
|
||||
// TODO Buffer sizes
|
||||
conn.torrentChannel = make(chan string, 1000)
|
||||
|
@ -48,7 +48,6 @@ func (d *driver) New(conf *config.DataStore) storage.Conn {
|
|||
}
|
||||
|
||||
type Conn struct {
|
||||
db *sql.DB
|
||||
waitGroup sync.WaitGroup
|
||||
terminate bool
|
||||
|
||||
|
@ -57,6 +56,8 @@ type Conn struct {
|
|||
transferHistoryChannel chan string
|
||||
transferIpsChannel chan string
|
||||
snatchChannel chan string
|
||||
|
||||
*sql.DB
|
||||
}
|
||||
|
||||
func (c *Conn) Start() error {
|
||||
|
@ -71,7 +72,7 @@ func (c *Conn) Start() error {
|
|||
func (c *Conn) Close() error {
|
||||
c.terminate = true
|
||||
c.waitGroup.Wait()
|
||||
return c.db.Close()
|
||||
return c.DB.Close()
|
||||
}
|
||||
|
||||
func (c *Conn) RecordAnnounce(delta *models.AnnounceDelta) error {
|
||||
|
|
Loading…
Add table
Reference in a new issue