Add man to exported functions/fields

This commit is contained in:
Širhoe Biazhkovič
2021-11-27 00:26:53 +03:00
committed by Lawrence, Rendall
parent 0a5ac35c4d
commit 360ac9d08d
11 changed files with 72 additions and 32 deletions

View File

@@ -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