Restructured to have subpackages, added server communication

This commit is contained in:
2013-02-20 23:43:01 -05:00
parent b193814371
commit 3fc3e3a963
10 changed files with 201 additions and 35 deletions

32
client/storage.go Normal file
View File

@ -0,0 +1,32 @@
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
}
default:
return nil, errors.New("Error: storage method '" + storageMethod + "' not implemented.")
}
return storage, nil
}