serverconfig: add 'memoryIndex' bool option to high-level config

Change-Id: If5edb272858f186931eeb57579e221bde3efb07c
This commit is contained in:
Brad Fitzpatrick 2013-11-28 11:09:16 -08:00
parent 3db0eca58c
commit 1defe7b297
3 changed files with 133 additions and 12 deletions

View File

@ -46,6 +46,7 @@ type configPrefixesParams struct {
searchOwner blob.Ref
shareHandlerPath string
flickr string
memoryIndex bool
}
var (
@ -506,12 +507,16 @@ func genLowLevelPrefixes(params *configPrefixesParams, ownerName string) (m json
},
}
m["/my-search/"] = map[string]interface{}{
"handler": "search",
"handlerArgs": map[string]interface{}{
searchArgs := map[string]interface{}{
"index": params.indexerPath,
"owner": params.searchOwner.String(),
},
}
if params.memoryIndex {
searchArgs["slurpToMemory"] = true
}
m["/my-search/"] = map[string]interface{}{
"handler": "search",
"handlerArgs": searchArgs,
}
}
@ -543,14 +548,15 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
shareHandlerPath = conf.OptionalString("shareHandlerPath", "")
// Index options
runIndex = conf.OptionalBool("runIndex", true) // if false: no search, no UI, etc.
dbname = conf.OptionalString("dbname", "") // for mysql, postgres, mongo
mysql = conf.OptionalString("mysql", "")
postgres = conf.OptionalString("postgres", "")
memIndex = conf.OptionalBool("memIndex", false)
mongo = conf.OptionalString("mongo", "")
sqliteFile = conf.OptionalString("sqlite", "")
kvFile = conf.OptionalString("kvIndexFile", "")
memoryIndex = conf.OptionalBool("memoryIndex", false)
runIndex = conf.OptionalBool("runIndex", true) // if false: no search, no UI, etc.
dbname = conf.OptionalString("dbname", "") // for mysql, postgres, mongo
mysql = conf.OptionalString("mysql", "")
postgres = conf.OptionalString("postgres", "")
memIndex = conf.OptionalBool("memIndex", false)
mongo = conf.OptionalString("mongo", "")
sqliteFile = conf.OptionalString("sqlite", "")
kvFile = conf.OptionalString("kvIndexFile", "")
// Importer options
flickr = conf.OptionalString("flickr", "")
@ -665,6 +671,7 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
searchOwner: blob.SHA1FromString(armoredPublicKey),
shareHandlerPath: shareHandlerPath,
flickr: flickr,
memoryIndex: memoryIndex,
}
prefixes := genLowLevelPrefixes(prefixesParams, ownerName)

View File

@ -0,0 +1,103 @@
{
"auth": "userpass:camlistore:pass3179",
"https": false,
"listen": "localhost:3179",
"prefixes": {
"/": {
"handler": "root",
"handlerArgs": {
"blobRoot": "/bs-and-maybe-also-index/",
"ownerName": "Alice",
"searchRoot": "/my-search/",
"statusRoot": "/status/",
"stealth": false
}
},
"/bs-and-index/": {
"handler": "storage-replica",
"handlerArgs": {
"backends": [
"/bs/",
"/index-kv/"
]
}
},
"/bs-and-maybe-also-index/": {
"handler": "storage-cond",
"handlerArgs": {
"read": "/bs/",
"write": {
"else": "/bs/",
"if": "isSchema",
"then": "/bs-and-index/"
}
}
},
"/bs/": {
"handler": "storage-filesystem",
"handlerArgs": {
"path": "/tmp/blobs"
}
},
"/cache/": {
"handler": "storage-filesystem",
"handlerArgs": {
"path": "/tmp/blobs/cache"
}
},
"/index-kv/": {
"handler": "storage-kvfileindexer",
"handlerArgs": {
"blobSource": "/bs/",
"file": "/path/to/indexkv.db"
}
},
"/my-search/": {
"handler": "search",
"handlerArgs": {
"index": "/index-kv/",
"owner": "sha1-f2b0b7da718b97ce8c31591d8ed4645c777f3ef4",
"slurpToMemory": true
}
},
"/setup/": {
"handler": "setup"
},
"/share/": {
"handler": "share",
"handlerArgs": {
"blobRoot": "/bs/"
}
},
"/sighelper/": {
"handler": "jsonsign",
"handlerArgs": {
"keyId": "26F5ABDA",
"publicKeyDest": "/bs-and-index/",
"secretRing": "/path/to/secring"
}
},
"/status/": {
"handler": "status"
},
"/sync/": {
"handler": "sync",
"handlerArgs": {
"from": "/bs/",
"queue": {
"file": "/tmp/blobs/sync-to-index-queue.kv",
"type": "kv"
},
"to": "/index-kv/"
}
},
"/ui/": {
"handler": "ui",
"handlerArgs": {
"cache": "/cache/",
"jsonSignRoot": "/sighelper/",
"scaledImage": "lrucache"
}
}
}
}

11
pkg/serverconfig/testdata/memindex.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"listen": "localhost:3179",
"auth": "userpass:camlistore:pass3179",
"blobPath": "/tmp/blobs",
"kvIndexFile": "/path/to/indexkv.db",
"memoryIndex": true,
"identity": "26F5ABDA",
"identitySecretRing": "/path/to/secring",
"ownerName": "Alice",
"shareHandlerPath": "/share/"
}