mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-28 00:20:01 -07:00
Add man to exported functions/fields
This commit is contained in:
committed by
Lawrence, Rendall
parent
0a5ac35c4d
commit
360ac9d08d
@@ -7,17 +7,21 @@ import (
|
||||
"sync"
|
||||
)
|
||||
|
||||
// DefaultStorageCtxName default ctx name if value from configuration is not set
|
||||
const DefaultStorageCtxName = "MW_APPROVAL"
|
||||
|
||||
// Builder function that creates and configures specific container
|
||||
type Builder func([]byte, storage.Storage) (Container, error)
|
||||
|
||||
var (
|
||||
buildersMU sync.Mutex
|
||||
builders = make(map[string]Builder)
|
||||
|
||||
// ErrContainerDoesNotExist holds error about nonexistent container
|
||||
ErrContainerDoesNotExist = errors.New("torrent hash container with that name does not exist")
|
||||
)
|
||||
|
||||
// Register used to register specific Builder in registry
|
||||
func Register(n string, c Builder) {
|
||||
if len(n) == 0 {
|
||||
panic("middleware: could not register a Container with an empty name")
|
||||
@@ -31,12 +35,13 @@ func Register(n string, c Builder) {
|
||||
builders[n] = c
|
||||
}
|
||||
|
||||
// Container holds InfoHash and checks if value approved or not
|
||||
type Container interface {
|
||||
Approved(bittorrent.InfoHash) bool
|
||||
}
|
||||
|
||||
// GetContainer creates Container by its name and provided confBytes
|
||||
func GetContainer(name string, confBytes []byte, storage storage.Storage) (Container, error) {
|
||||
|
||||
buildersMU.Lock()
|
||||
defer buildersMU.Unlock()
|
||||
var err error
|
||||
|
||||
Reference in New Issue
Block a user