diff --git a/main.go b/main.go index 3beac1a..51cebe2 100644 --- a/main.go +++ b/main.go @@ -15,9 +15,9 @@ import ( "github.com/pushrax/chihaya/config" "github.com/pushrax/chihaya/server" + _ "github.com/pushrax/chihaya/storage/backend/batter" + _ "github.com/pushrax/chihaya/storage/backend/gazelle" _ "github.com/pushrax/chihaya/storage/tracker/redis" - _ "github.com/pushrax/chihaya/storage/web/batter" - _ "github.com/pushrax/chihaya/storage/web/gazelle" ) var ( diff --git a/server/stats_test.go b/server/stats_test.go index f539266..29b44e7 100644 --- a/server/stats_test.go +++ b/server/stats_test.go @@ -13,8 +13,8 @@ import ( "github.com/pushrax/chihaya/config" + _ "github.com/pushrax/chihaya/storage/backend/batter" _ "github.com/pushrax/chihaya/storage/tracker/redis" - _ "github.com/pushrax/chihaya/storage/web/batter" ) func newTestServer() (*Server, error) { diff --git a/storage/web/web.go b/storage/backend/backend.go similarity index 94% rename from storage/web/web.go rename to storage/backend/backend.go index fd0180f..f2d0c07 100644 --- a/storage/web/web.go +++ b/storage/backend/backend.go @@ -2,9 +2,9 @@ // Use of this source code is governed by the BSD 2-Clause license, // which can be found in the LICENSE file. -// Package web provides a generic interface for manipulating a -// BitTorrent tracker's web application data. -package web +// Package backend provides a generic interface for manipulating a +// BitTorrent tracker's backend data (usually for a web application). +package backend import ( "fmt" diff --git a/storage/web/batter/batter.go b/storage/backend/batter/batter.go similarity index 81% rename from storage/web/batter/batter.go rename to storage/backend/batter/batter.go index 49e22e5..1aea1ea 100644 --- a/storage/web/batter/batter.go +++ b/storage/backend/batter/batter.go @@ -11,14 +11,14 @@ import ( "fmt" "github.com/pushrax/chihaya/config" - "github.com/pushrax/chihaya/storage/web" + "github.com/pushrax/chihaya/storage/backend" _ "github.com/bmizerany/pq" ) type driver struct{} -func (d *driver) New(conf *config.DataStore) web.Conn { +func (d *driver) New(conf *config.DataStore) backend.Conn { dsn := fmt.Sprintf( "host=%s user=%s password=%s dbname=%s", conf.Host, @@ -47,10 +47,10 @@ func (c *Conn) Start() error { return nil } -func (c *Conn) RecordAnnounce(delta *web.AnnounceDelta) error { +func (c *Conn) RecordAnnounce(delta *backend.AnnounceDelta) error { return nil } func init() { - web.Register("batter", &driver{}) + backend.Register("batter", &driver{}) } diff --git a/storage/web/batter/load.go b/storage/backend/batter/load.go similarity index 100% rename from storage/web/batter/load.go rename to storage/backend/batter/load.go diff --git a/storage/web/gazelle/flush.go b/storage/backend/gazelle/flush.go similarity index 100% rename from storage/web/gazelle/flush.go rename to storage/backend/gazelle/flush.go diff --git a/storage/web/gazelle/gazelle.go b/storage/backend/gazelle/gazelle.go similarity index 89% rename from storage/web/gazelle/gazelle.go rename to storage/backend/gazelle/gazelle.go index 58e08c4..015dd53 100644 --- a/storage/web/gazelle/gazelle.go +++ b/storage/backend/gazelle/gazelle.go @@ -12,14 +12,14 @@ import ( "sync" "github.com/pushrax/chihaya/config" - "github.com/pushrax/chihaya/storage/web" + "github.com/pushrax/chihaya/storage/backend" _ "github.com/go-sql-driver/mysql" ) type driver struct{} -func (d *driver) New(conf *config.DataStore) web.Conn { +func (d *driver) New(conf *config.DataStore) backend.Conn { dsn := fmt.Sprintf( "%s:%s@%s:%s/%s?charset=utf8mb4,utf8", conf.Username, @@ -77,7 +77,7 @@ func (c *Conn) Close() error { return c.DB.Close() } -func (c *Conn) RecordAnnounce(delta *web.AnnounceDelta) error { +func (c *Conn) RecordAnnounce(delta *backend.AnnounceDelta) error { snatchCount := 0 if delta.Snatched { snatchCount = 1 @@ -95,5 +95,5 @@ func (c *Conn) RecordAnnounce(delta *web.AnnounceDelta) error { } func init() { - web.Register("gazelle", &driver{}) + backend.Register("gazelle", &driver{}) } diff --git a/storage/web/gazelle/load.go b/storage/backend/gazelle/load.go similarity index 100% rename from storage/web/gazelle/load.go rename to storage/backend/gazelle/load.go