2013-12-02 11:00:28 +01:00
|
|
|
// Copyright 2013 The Chihaya Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by the BSD 2-Clause license,
|
|
|
|
// which can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package mock implements the storage interface for a BitTorrent tracker's
|
|
|
|
// backend storage. It can be used in production, but isn't recommended.
|
|
|
|
// Stored values will not persist if the tracker is restarted.
|
|
|
|
package mock
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/chihaya/chihaya/config"
|
2014-02-23 05:47:11 +01:00
|
|
|
"github.com/chihaya/chihaya/storage"
|
2013-12-02 11:00:28 +01:00
|
|
|
"github.com/chihaya/chihaya/storage/backend"
|
|
|
|
)
|
|
|
|
|
|
|
|
type driver struct{}
|
|
|
|
|
2014-02-23 05:47:11 +01:00
|
|
|
type mock struct{}
|
|
|
|
|
2013-12-02 11:00:28 +01:00
|
|
|
func (d *driver) New(conf *config.DataStore) backend.Conn {
|
2014-02-23 05:47:11 +01:00
|
|
|
return &mock{}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mock) Start() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mock) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mock) RecordAnnounce(delta *backend.AnnounceDelta) error {
|
2013-12-02 11:00:28 +01:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2014-02-23 05:47:11 +01:00
|
|
|
func (m *mock) LoadTorrents(ids []uint64) ([]*storage.Torrent, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mock) LoadAllTorrents() ([]*storage.Torrent, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mock) LoadUsers(ids []uint64) ([]*storage.User, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *mock) LoadAllUsers(ids []uint64) ([]*storage.User, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2013-12-02 11:00:28 +01:00
|
|
|
func init() {
|
|
|
|
backend.Register("mock", &driver{})
|
|
|
|
}
|