mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-20 06:44:48 -07:00
web package renamed backend
This commit is contained in:
4
main.go
4
main.go
@@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/pushrax/chihaya/config"
|
"github.com/pushrax/chihaya/config"
|
||||||
"github.com/pushrax/chihaya/server"
|
"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/tracker/redis"
|
||||||
_ "github.com/pushrax/chihaya/storage/web/batter"
|
|
||||||
_ "github.com/pushrax/chihaya/storage/web/gazelle"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ import (
|
|||||||
|
|
||||||
"github.com/pushrax/chihaya/config"
|
"github.com/pushrax/chihaya/config"
|
||||||
|
|
||||||
|
_ "github.com/pushrax/chihaya/storage/backend/batter"
|
||||||
_ "github.com/pushrax/chihaya/storage/tracker/redis"
|
_ "github.com/pushrax/chihaya/storage/tracker/redis"
|
||||||
_ "github.com/pushrax/chihaya/storage/web/batter"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func newTestServer() (*Server, error) {
|
func newTestServer() (*Server, error) {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
// Use of this source code is governed by the BSD 2-Clause license,
|
// Use of this source code is governed by the BSD 2-Clause license,
|
||||||
// which can be found in the LICENSE file.
|
// which can be found in the LICENSE file.
|
||||||
|
|
||||||
// Package web provides a generic interface for manipulating a
|
// Package backend provides a generic interface for manipulating a
|
||||||
// BitTorrent tracker's web application data.
|
// BitTorrent tracker's backend data (usually for a web application).
|
||||||
package web
|
package backend
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -11,14 +11,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/pushrax/chihaya/config"
|
"github.com/pushrax/chihaya/config"
|
||||||
"github.com/pushrax/chihaya/storage/web"
|
"github.com/pushrax/chihaya/storage/backend"
|
||||||
|
|
||||||
_ "github.com/bmizerany/pq"
|
_ "github.com/bmizerany/pq"
|
||||||
)
|
)
|
||||||
|
|
||||||
type driver struct{}
|
type driver struct{}
|
||||||
|
|
||||||
func (d *driver) New(conf *config.DataStore) web.Conn {
|
func (d *driver) New(conf *config.DataStore) backend.Conn {
|
||||||
dsn := fmt.Sprintf(
|
dsn := fmt.Sprintf(
|
||||||
"host=%s user=%s password=%s dbname=%s",
|
"host=%s user=%s password=%s dbname=%s",
|
||||||
conf.Host,
|
conf.Host,
|
||||||
@@ -47,10 +47,10 @@ func (c *Conn) Start() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) RecordAnnounce(delta *web.AnnounceDelta) error {
|
func (c *Conn) RecordAnnounce(delta *backend.AnnounceDelta) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
web.Register("batter", &driver{})
|
backend.Register("batter", &driver{})
|
||||||
}
|
}
|
||||||
@@ -12,14 +12,14 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/pushrax/chihaya/config"
|
"github.com/pushrax/chihaya/config"
|
||||||
"github.com/pushrax/chihaya/storage/web"
|
"github.com/pushrax/chihaya/storage/backend"
|
||||||
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
type driver struct{}
|
type driver struct{}
|
||||||
|
|
||||||
func (d *driver) New(conf *config.DataStore) web.Conn {
|
func (d *driver) New(conf *config.DataStore) backend.Conn {
|
||||||
dsn := fmt.Sprintf(
|
dsn := fmt.Sprintf(
|
||||||
"%s:%s@%s:%s/%s?charset=utf8mb4,utf8",
|
"%s:%s@%s:%s/%s?charset=utf8mb4,utf8",
|
||||||
conf.Username,
|
conf.Username,
|
||||||
@@ -77,7 +77,7 @@ func (c *Conn) Close() error {
|
|||||||
return c.DB.Close()
|
return c.DB.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Conn) RecordAnnounce(delta *web.AnnounceDelta) error {
|
func (c *Conn) RecordAnnounce(delta *backend.AnnounceDelta) error {
|
||||||
snatchCount := 0
|
snatchCount := 0
|
||||||
if delta.Snatched {
|
if delta.Snatched {
|
||||||
snatchCount = 1
|
snatchCount = 1
|
||||||
@@ -95,5 +95,5 @@ func (c *Conn) RecordAnnounce(delta *web.AnnounceDelta) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
web.Register("gazelle", &driver{})
|
backend.Register("gazelle", &driver{})
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user