Make s3 storage use registry; start trimming blobserver

This commit is contained in:
Brad Fitzpatrick 2011-04-01 20:45:40 -07:00
parent 00f9ede8a6
commit 63668853d9
3 changed files with 15 additions and 17 deletions

View File

@ -27,7 +27,6 @@ import (
type diskStorage struct {
*blobserver.SimpleBlobHubPartitionMap
root string
}
func New(root string) (storage blobserver.Storage, err os.Error) {

View File

@ -32,3 +32,12 @@ func New(bucketPrefixURL, accessKey, secretAccessKey string) (storage blobserver
&blobserver.NoImplStorage{},
}, nil
}
func newFromConfig(config map[string]interface{}) (storage blobserver.Storage, err os.Error) {
// TODO: implement
return nil, os.NewError("not implemented")
}
func init() {
blobserver.RegisterStorageConstructor("filesystem", blobserver.StorageConstructor(newFromConfig))
}

View File

@ -24,6 +24,7 @@ import (
"camli/webserver"
"camli/blobserver"
"camli/blobserver/localdisk"
_ "camli/blobserver/s3"
"camli/blobserver/handlers"
"camli/mysqlindexer" // TODO: temporary for testing; wrong place kinda
"camli/search" // TODO: temporary for testing; wrong place kinda
@ -232,25 +233,14 @@ func commandLineConfigurationMain() {
exitFailure("No CAMLI_PASSWORD environment variable set.")
}
rootPrefix := func(s string) bool {
return strings.HasPrefix(*flagStorageRoot, s)
}
switch {
case *flagStorageRoot == "":
if *flagStorageRoot == "" {
exitFailure("No storage root specified in --root")
case rootPrefix("s3:"):
// TODO: support Amazon, etc.
default:
var err os.Error
storage, err = localdisk.New(*flagStorageRoot)
if err != nil {
exitFailure("Error for --root of %q: %v", *flagStorageRoot, err)
}
}
if storage == nil {
exitFailure("Unsupported storage root type %q", *flagStorageRoot)
var err os.Error
storage, err = localdisk.New(*flagStorageRoot)
if err != nil {
exitFailure("Error for --root of %q: %v", *flagStorageRoot, err)
}
ws := webserver.New()