camlistored: in config, prefix all storage handlers with 'storage-'

This commit is contained in:
Brad Fitzpatrick 2011-05-29 22:28:17 -07:00
parent 121290c9d1
commit 0385f7baaa
5 changed files with 30 additions and 25 deletions

View File

@ -7,7 +7,7 @@
"prefixes": {
"/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT}"]
}

View File

@ -3,7 +3,7 @@
"password": ["_env", "${CAMLI_PASSWORD}"],
"prefixes": {
"/indexer/": {
"handler": "mysqlindexer",
"handler": "storage-mysqlindexer",
"handlerArgs": {
"database": "devcamlistore",
"user": "root",

View File

@ -34,35 +34,35 @@
},
"/bs/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT}"]
}
},
"/sharder/": {
"handler": "shard",
"handler": "storage-shard",
"handlerArgs": {
"backends": ["/s1/", "/s2/"]
}
},
"/s1/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT_SHARD1}"]
}
},
"/s2/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT_SHARD2}"]
}
},
"/repl/": {
"handler": "replica",
"handler": "storage-replica",
"handlerArgs": {
"backends": ["/r1/", "/r2/", "/r3/"],
"minWritesForSuccess": 2
@ -70,28 +70,28 @@
},
"/r1/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT_REPLICA1}"]
}
},
"/r2/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT_REPLICA2}"]
}
},
"/r3/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT_REPLICA3}"]
}
},
"/indexer/": {
"handler": "mysqlindexer",
"handler": "storage-mysqlindexer",
"handlerArgs": {
"database": "devcamlistore",
"user": "root",

View File

@ -3,7 +3,7 @@
"password": ["_env", "${CAMLI_PASSWORD}"],
"prefixes": {
"/": {
"handler": "filesystem",
"handler": "storage-filesystem",
"handlerArgs": {
"path": ["_env", "${CAMLI_ROOT}"]
}

View File

@ -303,20 +303,26 @@ func (hl *handlerLoader) setupHandler(prefix string) {
panic(fmt.Sprintf("setupHandler for %q didn't install a handler", prefix))
}
}()
if strings.HasPrefix(h.htype, "storage-") {
stype := h.htype[len("storage-"):]
// Assume a storage interface
pstorage, err := blobserver.CreateStorage(stype, hl, h.conf)
if err != nil {
exitFailure("error instantiating storage for prefix %q, type %q: %v",
h.prefix, stype, err)
}
hl.handler[h.prefix] = pstorage
hl.ws.Handle(prefix+"camli/", makeCamliHandler(prefix, hl.baseURL, pstorage))
return
}
checkConfig := func() {
if err := h.conf.Validate(); err != nil {
exitFailure("configuration error in \"handlerArgs\" for prefix %s: %v", prefix, err)
}
}
switch h.htype {
case "ui", "root", "jsonsign":
hh, err := blobserver.CreateHandler(h.htype, hl, h.conf)
if err != nil {
exitFailure("error instantiating handler for prefix %q, type %q: %v",
h.prefix, h.htype, err)
}
hl.handler[prefix] = hh
hl.ws.Handle(prefix, &httputil.PrefixHandler{prefix, hh})
case "search": // TODO: use blobserver registry
indexPrefix := h.conf.RequiredString("index") // TODO: add optional help tips here?
ownerBlobStr := h.conf.RequiredString("owner")
@ -353,13 +359,12 @@ func (hl *handlerLoader) setupHandler(prefix string) {
hl.handler[h.prefix] = synch
hl.ws.Handle(prefix, synch)
default:
// Assume a storage interface
pstorage, err := blobserver.CreateStorage(h.htype, hl, h.conf)
hh, err := blobserver.CreateHandler(h.htype, hl, h.conf)
if err != nil {
exitFailure("error instantiating storage for prefix %q, type %q: %v",
exitFailure("error instantiating handler for prefix %q, type %q: %v",
h.prefix, h.htype, err)
}
hl.handler[h.prefix] = pstorage
hl.ws.Handle(prefix+"camli/", makeCamliHandler(prefix, hl.baseURL, pstorage))
hl.handler[prefix] = hh
hl.ws.Handle(prefix, &httputil.PrefixHandler{prefix, hh})
}
}