Continue reorganization, add asinkd stop cmd, make asinkd socket configurable

This commit is contained in:
2013-09-02 23:35:48 -04:00
parent 2599717d09
commit 4eb75e1db1
15 changed files with 55 additions and 11 deletions

37
asink/storage.go Normal file
View File

@ -0,0 +1,37 @@
package main
import (
"code.google.com/p/goconf/conf"
"errors"
)
type Storage interface {
Put(filename string, hash string) error
Get(filename string, hash string) error
}
func GetStorage(config *conf.ConfigFile) (Storage, error) {
storageMethod, err := config.GetString("storage", "method")
if err != nil {
return nil, errors.New("Error: storage method not specified in config file.")
}
var storage Storage
switch storageMethod {
case "local":
storage, err = NewLocalStorage(config)
if err != nil {
return nil, err
}
case "ftp":
storage, err = NewFTPStorage(config)
if err != nil {
return nil, err
}
default:
return nil, errors.New("Error: storage method '" + storageMethod + "' not found.")
}
return storage, nil
}