mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-13 03:58:36 -07:00
Embed *db.Sql into storage/gazelle
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
|||||||
"github.com/pushrax/chihaya/config"
|
"github.com/pushrax/chihaya/config"
|
||||||
|
|
||||||
_ "github.com/pushrax/chihaya/cache/redis"
|
_ "github.com/pushrax/chihaya/cache/redis"
|
||||||
_ "github.com/pushrax/chihaya/storage/batter"
|
_ "github.com/pushrax/chihaya/storage/gazelle"
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestServer() (*Server, error) {
|
func newTestServer() (*Server, error) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ func (c *Conn) flushTorrents() {
|
|||||||
"Seeders = VALUES(Seeders), Leechers = VALUES(Leechers), " +
|
"Seeders = VALUES(Seeders), Leechers = VALUES(Leechers), " +
|
||||||
"last_action = IF(last_action < VALUES(last_action), VALUES(last_action), last_action);")
|
"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 {
|
if length < cap(c.torrentChannel)/2 {
|
||||||
time.Sleep(200 * time.Millisecond)
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ func (d *driver) New(conf *config.DataStore) storage.Conn {
|
|||||||
}
|
}
|
||||||
db.SetMaxIdleConns(conf.MaxIdleConns)
|
db.SetMaxIdleConns(conf.MaxIdleConns)
|
||||||
|
|
||||||
conn := &Conn{db: db}
|
conn := &Conn{DB: db}
|
||||||
|
|
||||||
// TODO Buffer sizes
|
// TODO Buffer sizes
|
||||||
conn.torrentChannel = make(chan string, 1000)
|
conn.torrentChannel = make(chan string, 1000)
|
||||||
@@ -48,7 +48,6 @@ func (d *driver) New(conf *config.DataStore) storage.Conn {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Conn struct {
|
type Conn struct {
|
||||||
db *sql.DB
|
|
||||||
waitGroup sync.WaitGroup
|
waitGroup sync.WaitGroup
|
||||||
terminate bool
|
terminate bool
|
||||||
|
|
||||||
@@ -57,6 +56,8 @@ type Conn struct {
|
|||||||
transferHistoryChannel chan string
|
transferHistoryChannel chan string
|
||||||
transferIpsChannel chan string
|
transferIpsChannel chan string
|
||||||
snatchChannel chan string
|
snatchChannel chan string
|
||||||
|
|
||||||
|
*sql.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) Start() error {
|
func (c *Conn) Start() error {
|
||||||
@@ -71,7 +72,7 @@ func (c *Conn) Start() error {
|
|||||||
func (c *Conn) Close() error {
|
func (c *Conn) Close() error {
|
||||||
c.terminate = true
|
c.terminate = true
|
||||||
c.waitGroup.Wait()
|
c.waitGroup.Wait()
|
||||||
return c.db.Close()
|
return c.DB.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) RecordAnnounce(delta *models.AnnounceDelta) error {
|
func (c *Conn) RecordAnnounce(delta *models.AnnounceDelta) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user