2015-01-01 18:02:25 +01:00
|
|
|
// Copyright 2015 The Chihaya Authors. All rights reserved.
|
2014-07-15 06:22:04 +02:00
|
|
|
// Use of this source code is governed by the BSD 2-Clause license,
|
|
|
|
// which can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package noop implements a Chihaya backend storage driver as a no-op. This is
|
|
|
|
// useful for running Chihaya as a public tracker.
|
|
|
|
package noop
|
|
|
|
|
|
|
|
import (
|
2014-07-17 07:26:34 +02:00
|
|
|
"github.com/chihaya/chihaya/backend"
|
2014-07-17 07:45:14 +02:00
|
|
|
"github.com/chihaya/chihaya/config"
|
2014-07-17 06:09:56 +02:00
|
|
|
"github.com/chihaya/chihaya/tracker/models"
|
2014-07-15 06:22:04 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type driver struct{}
|
|
|
|
|
2015-02-08 23:14:48 +01:00
|
|
|
// NoOp is a backend driver for Chihaya that does nothing. This is used by
|
|
|
|
// public trackers.
|
2014-07-15 06:22:04 +02:00
|
|
|
type NoOp struct{}
|
|
|
|
|
|
|
|
// New returns a new Chihaya backend driver that does nothing.
|
|
|
|
func (d *driver) New(cfg *config.DriverConfig) (backend.Conn, error) {
|
|
|
|
return &NoOp{}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close returns nil.
|
|
|
|
func (n *NoOp) Close() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-02-08 23:14:48 +01:00
|
|
|
// Ping returns nil.
|
|
|
|
func (n *NoOp) Ping() error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2014-07-15 06:22:04 +02:00
|
|
|
// RecordAnnounce returns nil.
|
|
|
|
func (n *NoOp) RecordAnnounce(delta *models.AnnounceDelta) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadTorrents returns (nil, nil).
|
|
|
|
func (n *NoOp) LoadTorrents(ids []uint64) ([]*models.Torrent, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadAllTorrents returns (nil, nil).
|
|
|
|
func (n *NoOp) LoadAllTorrents() ([]*models.Torrent, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadUsers returns (nil, nil).
|
|
|
|
func (n *NoOp) LoadUsers(ids []uint64) ([]*models.User, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// LoadAllUsers returns (nil, nil).
|
|
|
|
func (n *NoOp) LoadAllUsers(ids []uint64) ([]*models.User, error) {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2014-07-19 01:09:06 +02:00
|
|
|
// Init registers the noop driver as a backend for Chihaya.
|
2014-07-15 06:22:04 +02:00
|
|
|
func init() {
|
|
|
|
backend.Register("noop", &driver{})
|
|
|
|
}
|