diff --git a/build.pl b/build.pl index 1c6fe38e9..c81586398 100755 --- a/build.pl +++ b/build.pl @@ -462,6 +462,7 @@ TARGET: clients/go/camsync TARGET: lib/go/camli/auth TARGET: lib/go/camli/blobref TARGET: lib/go/camli/blobserver +TARGET: lib/go/camli/blobserver/cond TARGET: lib/go/camli/blobserver/handlers TARGET: lib/go/camli/blobserver/localdisk TARGET: lib/go/camli/blobserver/remote diff --git a/config/dev-server-config.json b/config/dev-server-config.json index 8964c13ae..e0dec7228 100644 --- a/config/dev-server-config.json +++ b/config/dev-server-config.json @@ -34,6 +34,22 @@ } }, + "/bs-and-index/": { + "handler": "storage-replica", + "handlerArgs": { + "backends": ["/bs/", "/indexer/"] + } + }, + + "/bs-and-maybe-also-index/": { + "handler": "storage-cond", + "handlerArgs": { + "if": "isSchema", + "then": "/bs-and-index/", + "else": "/bs/" + } + }, + "/bs/": { "handler": "storage-filesystem", "handlerArgs": { diff --git a/lib/go/camli/blobserver/cond/cond.go b/lib/go/camli/blobserver/cond/cond.go new file mode 100644 index 000000000..e2ed864ce --- /dev/null +++ b/lib/go/camli/blobserver/cond/cond.go @@ -0,0 +1,84 @@ +/* +Copyright 2011 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cond + +import ( + "io" + "log" + "os" + + "camli/blobref" + "camli/blobserver" + "camli/jsonconfig" +) + +var _ = log.Printf + +const buffered = 8 + +type condStorage struct { + *blobserver.SimpleBlobHubPartitionMap + +} + +func (sto *condStorage) GetBlobHub() blobserver.BlobHub { + return sto.SimpleBlobHubPartitionMap.GetBlobHub() +} + +func newFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (storage blobserver.Storage, err os.Error) { + sto := &condStorage{ + SimpleBlobHubPartitionMap: &blobserver.SimpleBlobHubPartitionMap{}, + } + _ = conf.RequiredString("if") + _ = conf.RequiredString("then") + _ = conf.RequiredString("else") + if err := conf.Validate(); err != nil { + return nil, err + } + return sto, nil +} + +func (sto *condStorage) FetchStreaming(b *blobref.BlobRef) (file io.ReadCloser, size int64, err os.Error) { + panic("NOIMPL") + return nil, 0, nil +} + +func (sto *condStorage) Stat(dest chan<- blobref.SizedBlobRef, blobs []*blobref.BlobRef, waitSeconds int) os.Error { + panic("NOIMPL") + return nil +} + +func (sto *condStorage) ReceiveBlob(b *blobref.BlobRef, source io.Reader) (xxgo blobref.SizedBlobRef, err os.Error) { + var sb blobref.SizedBlobRef + panic("NOIMPL") + return sb, nil +} + +func (sto *condStorage) Remove(blobs []*blobref.BlobRef) os.Error { + panic("NOIMPL") + return nil +} + + +func (sto *condStorage) EnumerateBlobs(dest chan<- blobref.SizedBlobRef, after string, limit uint, waitSeconds int) os.Error { + panic("NOIMPL") + return nil +} + +func init() { + blobserver.RegisterStorageConstructor("cond", blobserver.StorageConstructor(newFromConfig)) +} diff --git a/server/go/camlistored/camlistored.go b/server/go/camlistored/camlistored.go index aa819e8ca..f6809c696 100644 --- a/server/go/camlistored/camlistored.go +++ b/server/go/camlistored/camlistored.go @@ -36,6 +36,7 @@ import ( "camli/webserver" // Storage options: + _ "camli/blobserver/cond" _ "camli/blobserver/localdisk" _ "camli/blobserver/remote" _ "camli/blobserver/replica"