2011-02-03 23:45:35 +00:00
|
|
|
/*
|
|
|
|
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 blobserver
|
|
|
|
|
|
|
|
import (
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"errors"
|
2011-02-04 22:31:23 +00:00
|
|
|
"io"
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"net/http"
|
2011-02-03 23:45:35 +00:00
|
|
|
"os"
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"time"
|
2011-10-07 00:44:30 +00:00
|
|
|
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
"camlistore.org/pkg/blobref"
|
2011-02-03 23:45:35 +00:00
|
|
|
)
|
|
|
|
|
2013-01-01 01:36:28 +00:00
|
|
|
// MaxBlobSize is the size of a single blob in Camlistore.
|
|
|
|
//
|
|
|
|
// TODO: formalize this in the specs. This value of 16 MB is less than
|
|
|
|
// App Engine's 32 MB request limit, much more than Venti's limit, and
|
|
|
|
// much more than the ~64 KB & 256 KB chunks that the FileWriter make
|
|
|
|
const MaxBlobSize = 16 << 20
|
|
|
|
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
var ErrCorruptBlob = errors.New("corrupt blob; digest doesn't match")
|
2011-03-06 17:28:02 +00:00
|
|
|
|
2011-02-04 22:31:23 +00:00
|
|
|
type BlobReceiver interface {
|
2011-03-05 08:03:53 +00:00
|
|
|
// ReceiveBlob accepts a newly uploaded blob and writes it to
|
|
|
|
// disk.
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
ReceiveBlob(blob *blobref.BlobRef, source io.Reader) (blobref.SizedBlobRef, error)
|
2011-02-04 22:31:23 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 16:24:16 +00:00
|
|
|
type BlobStatter interface {
|
|
|
|
// Stat checks for the existence of blobs, writing their sizes
|
|
|
|
// (if found back to the dest channel), and returning an error
|
|
|
|
// or nil. Stat() should NOT close the channel.
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
// wait is the max time to wait for the blobs to exist,
|
2011-05-09 16:11:18 +00:00
|
|
|
// or 0 for no delay.
|
2011-09-29 02:37:28 +00:00
|
|
|
StatBlobs(dest chan<- blobref.SizedBlobRef,
|
2011-10-11 01:04:20 +00:00
|
|
|
blobs []*blobref.BlobRef,
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
wait time.Duration) error
|
2011-02-26 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
func StatBlob(bs BlobStatter, br *blobref.BlobRef) (sb blobref.SizedBlobRef, err error) {
|
2011-10-26 02:40:50 +00:00
|
|
|
c := make(chan blobref.SizedBlobRef, 1)
|
|
|
|
err = bs.StatBlobs(c, []*blobref.BlobRef{br}, 0)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
select {
|
|
|
|
case sb = <-c:
|
|
|
|
default:
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
err = os.ErrNotExist
|
2011-10-26 02:40:50 +00:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2011-09-29 02:37:28 +00:00
|
|
|
type StatReceiver interface {
|
|
|
|
BlobReceiver
|
|
|
|
BlobStatter
|
|
|
|
}
|
|
|
|
|
2011-05-09 18:08:14 +00:00
|
|
|
// QueueCreator is implemented by Storage interfaces which support
|
|
|
|
// creating queues in which all new uploads go to both the root
|
|
|
|
// storage as well as the named queue, which is then returned. This
|
|
|
|
// is used by replication.
|
|
|
|
type QueueCreator interface {
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
CreateQueue(name string) (Storage, error)
|
2011-05-09 18:08:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 04:03:43 +00:00
|
|
|
type MaxEnumerateConfig interface {
|
|
|
|
// Returns the max that this storage interface is capable
|
|
|
|
// of enumerating at once.
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
MaxEnumerate() int
|
2011-04-09 04:03:43 +00:00
|
|
|
}
|
|
|
|
|
2011-02-26 22:03:10 +00:00
|
|
|
type BlobEnumerator interface {
|
|
|
|
// EnumerateBobs sends at most limit SizedBlobRef into dest,
|
|
|
|
// sorted, as long as they are lexigraphically greater than
|
|
|
|
// after (if provided).
|
2011-03-06 00:23:12 +00:00
|
|
|
// limit will be supplied and sanity checked by caller.
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
// wait is the max time to wait for any blobs to exist,
|
2011-05-09 16:11:18 +00:00
|
|
|
// or 0 for no delay.
|
2011-03-25 16:52:51 +00:00
|
|
|
// EnumerateBlobs must close the channel. (even if limit
|
|
|
|
// was hit and more blobs remain)
|
2011-05-11 13:11:44 +00:00
|
|
|
//
|
|
|
|
// after and waitSeconds can't be used together. One must be
|
|
|
|
// its zero value.
|
2011-05-10 23:13:37 +00:00
|
|
|
EnumerateBlobs(dest chan<- blobref.SizedBlobRef,
|
2011-10-11 01:04:20 +00:00
|
|
|
after string,
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
limit int,
|
|
|
|
wait time.Duration) error
|
2011-02-08 16:24:16 +00:00
|
|
|
}
|
|
|
|
|
2011-03-25 02:57:57 +00:00
|
|
|
// Cache is the minimal interface expected of a blob cache.
|
|
|
|
type Cache interface {
|
2011-06-04 16:12:02 +00:00
|
|
|
blobref.SeekFetcher
|
2011-03-25 02:57:57 +00:00
|
|
|
BlobReceiver
|
|
|
|
BlobStatter
|
|
|
|
}
|
2011-03-07 04:11:36 +00:00
|
|
|
|
2011-05-10 21:55:12 +00:00
|
|
|
type BlobReceiveConfiger interface {
|
|
|
|
BlobReceiver
|
|
|
|
Configer
|
|
|
|
}
|
|
|
|
|
2011-05-09 16:11:18 +00:00
|
|
|
type Config struct {
|
|
|
|
Writable, Readable bool
|
2011-05-10 21:55:12 +00:00
|
|
|
IsQueue bool // supports deletes
|
2011-10-11 01:04:20 +00:00
|
|
|
CanLongPoll bool
|
2011-05-09 16:11:18 +00:00
|
|
|
|
|
|
|
// the "http://host:port" and optional path (but without trailing slash) to have "/camli/*" appended
|
2012-12-29 14:51:42 +00:00
|
|
|
URLBase string
|
|
|
|
HandlerFinder FindHandlerByTyper
|
2011-05-09 16:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Configer interface {
|
|
|
|
Config() *Config
|
|
|
|
}
|
|
|
|
|
2012-11-07 19:55:37 +00:00
|
|
|
// A GenerationNotSupportedError explains why a Storage
|
|
|
|
// value implemented the Generationer interface but failed due
|
|
|
|
// to a wrapped Storage value not implementing the interface.
|
|
|
|
type GenerationNotSupportedError string
|
|
|
|
|
|
|
|
func (s GenerationNotSupportedError) Error() string { return string(s) }
|
|
|
|
|
|
|
|
/*
|
|
|
|
The optional Generationer interface is an optimization and paranoia
|
|
|
|
facility for clients which can be implemented by Storage
|
|
|
|
implementations.
|
|
|
|
|
|
|
|
If the client sees the same random string in multiple upload sessions,
|
|
|
|
it assumes that the blobserver still has all the same blobs, and also
|
|
|
|
it's the same server. This mechanism is not fundamental to
|
|
|
|
Camlistore's operation: the client could also check each blob before
|
|
|
|
uploading, or enumerate all blobs from the server too. This is purely
|
|
|
|
an optimization so clients can mix this value into their "is this file
|
|
|
|
uploaded?" local cache keys.
|
|
|
|
*/
|
|
|
|
type Generationer interface {
|
|
|
|
// Generation returns a Storage's initialization time and
|
|
|
|
// and unique random string (or UUID). Implementations
|
|
|
|
// should call ResetStorageGeneration on demand if no
|
|
|
|
// information is known.
|
|
|
|
// The error will be of type GenerationNotSupportedError if an underlying
|
|
|
|
// storage target doesn't support the Generationer interface.
|
|
|
|
StorageGeneration() (initTime time.Time, random string, err error)
|
|
|
|
|
|
|
|
// ResetGeneration deletes the information returned by Generation
|
|
|
|
// and re-generates it.
|
|
|
|
ResetStorageGeneration() error
|
|
|
|
}
|
|
|
|
|
2013-07-07 23:09:17 +00:00
|
|
|
// Storage is the interface that must be implemented by a blobserver
|
|
|
|
// storage type. (e.g. localdisk, s3, encrypt, shard, replica, remote)
|
2011-02-03 23:45:35 +00:00
|
|
|
type Storage interface {
|
2011-04-09 06:20:24 +00:00
|
|
|
blobref.StreamingFetcher
|
2011-02-04 22:31:23 +00:00
|
|
|
BlobReceiver
|
2011-02-08 16:24:16 +00:00
|
|
|
BlobStatter
|
2011-02-26 22:03:10 +00:00
|
|
|
BlobEnumerator
|
2013-07-08 04:12:18 +00:00
|
|
|
BlobRemover
|
2011-02-03 23:45:35 +00:00
|
|
|
|
2013-07-08 04:12:18 +00:00
|
|
|
// GetBlobHub returns the blob notification bus.
|
|
|
|
GetBlobHub() BlobHub
|
|
|
|
}
|
|
|
|
|
|
|
|
type BlobRemover interface {
|
2013-07-07 23:09:17 +00:00
|
|
|
// RemoveBlobs removes 0 or more blobs. Removal of
|
|
|
|
// non-existent items isn't an error. Returns failure if any
|
|
|
|
// items existed but failed to be deleted.
|
Update from r60 to [almost] Go 1.
A lot is still broken, but most stuff at least compiles now.
The directory tree has been rearranged now too. Go libraries are now
under "pkg". Fully qualified, they are e.g. "camlistore.org/pkg/jsonsign".
The go tool cannot yet fetch from arbitrary domains, but discussion is
happening now on which mechanism to use to allow that.
For now, put the camlistore root under $GOPATH/src. Typically $GOPATH
is $HOME, so Camlistore should be at $HOME/src/camlistore.org.
Then you can:
$ go build ./server/camlistored
... etc
The build.pl script is currently disabled. It'll be resurrected at
some point, but with a very different role (helping create a fake
GOPATH and running the go build command, if things are installed at
the wrong place, and/or running fileembed generators).
Many things are certainly broken.
Many things are disabled. (MySQL, all indexing, etc).
Many things need to be moved into
camlistore.org/third_party/{code.google.com,github.com} and updated
from their r60 to Go 1 versions, where applicable.
The GoMySQL stuff should be updated to use database/sql and the ziutek
library implementing database/sql/driver.
Help wanted.
Change-Id: If71217dc5c8f0e70dbe46e9504ca5131c6eeacde
2012-02-19 05:53:06 +00:00
|
|
|
RemoveBlobs(blobs []*blobref.BlobRef) error
|
2011-02-03 23:45:35 +00:00
|
|
|
}
|
2011-05-10 21:55:12 +00:00
|
|
|
|
|
|
|
type StorageConfiger interface {
|
|
|
|
Storage
|
|
|
|
Configer
|
|
|
|
}
|
2011-10-07 00:44:30 +00:00
|
|
|
|
2011-12-04 23:19:28 +00:00
|
|
|
type StorageQueueCreator interface {
|
|
|
|
Storage
|
|
|
|
QueueCreator
|
|
|
|
}
|
|
|
|
|
2011-10-07 00:44:30 +00:00
|
|
|
// ContextWrapper is an optional interface for App Engine.
|
|
|
|
//
|
|
|
|
// While Camlistore's internals are separated out into a part which
|
2012-12-25 18:19:33 +00:00
|
|
|
// maps HTTP requests to the interfaces in this file
|
2012-05-13 15:07:13 +00:00
|
|
|
// (pkg/blobserver/handlers) and parts which map these
|
2011-10-07 00:44:30 +00:00
|
|
|
// interfaces to implementations (localdisk, s3, etc), the App Engine
|
|
|
|
// implementation requires access to the original HTTP
|
|
|
|
// request. (because a security token is stored on the incoming HTTP
|
|
|
|
// request in a magic header). All the handlers will do an interface
|
|
|
|
// check on this type and use the resulting Storage instead.
|
|
|
|
type ContextWrapper interface {
|
|
|
|
WrapContext(*http.Request) Storage
|
|
|
|
}
|
2011-10-28 05:08:55 +00:00
|
|
|
|
|
|
|
func MaybeWrapContext(sto Storage, req *http.Request) Storage {
|
|
|
|
if req == nil {
|
|
|
|
return sto
|
|
|
|
}
|
|
|
|
w, ok := sto.(ContextWrapper)
|
|
|
|
if !ok {
|
|
|
|
return sto
|
|
|
|
}
|
|
|
|
return w.WrapContext(req)
|
|
|
|
}
|
2012-12-22 21:50:55 +00:00
|
|
|
|
|
|
|
// Unwrap returns the wrapped Storage interface, if wrapped, else returns sto.
|
|
|
|
func Unwrap(sto interface{}) interface{} {
|
|
|
|
type get interface {
|
|
|
|
GetStorage() Storage
|
|
|
|
}
|
|
|
|
if g, ok := sto.(get); ok {
|
|
|
|
return Unwrap(g.GetStorage())
|
|
|
|
}
|
|
|
|
return sto
|
2012-12-29 14:51:42 +00:00
|
|
|
}
|