mirror of
https://github.com/sot-tech/mochi.git
synced 2026-05-22 07:44:48 -07:00
repurpose drivers from mock to no-op and memory
This commit is contained in:
56
drivers/backend/noop/driver.go
Normal file
56
drivers/backend/noop/driver.go
Normal file
@@ -0,0 +1,56 @@
|
||||
// Copyright 2014 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 noop implements a Chihaya backend storage driver as a no-op. This is
|
||||
// useful for running Chihaya as a public tracker.
|
||||
package noop
|
||||
|
||||
import (
|
||||
"github.com/chihaya/chihaya/config"
|
||||
"github.com/chihaya/chihaya/drivers/backend"
|
||||
"github.com/chihaya/chihaya/models"
|
||||
)
|
||||
|
||||
type driver struct{}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
func init() {
|
||||
backend.Register("noop", &driver{})
|
||||
}
|
||||
Reference in New Issue
Block a user