Introduce type Server

This commit is contained in:
Alexander Neumann 2014-12-21 17:02:49 +01:00
parent 661c1e9aa1
commit cc147c002e
15 changed files with 206 additions and 106 deletions

View file

@ -22,8 +22,8 @@ var (
// Each lists all entries of type t in the backend and calls function f() with
// the id and data.
func Each(be interface {
lister
getter
Lister
Getter
}, t Type, f func(id ID, data []byte, err error)) error {
ids, err := be.List(t)
if err != nil {
@ -45,7 +45,7 @@ func Each(be interface {
// Each lists all entries of type t in the backend and calls function f() with
// the id.
func EachID(be lister, t Type, f func(ID)) error {
func EachID(be Lister, t Type, f func(ID)) error {
ids, err := be.List(t)
if err != nil {
return err
@ -101,7 +101,7 @@ func Hash(data []byte) ID {
// Find loads the list of all blobs of type t and searches for IDs which start
// with prefix. If none is found, nil and ErrNoIDPrefixFound is returned. If
// more than one is found, nil and ErrMultipleIDMatches is returned.
func Find(be lister, t Type, prefix string) (ID, error) {
func Find(be Lister, t Type, prefix string) (ID, error) {
p, err := hex.DecodeString(prefix)
if err != nil {
return nil, err
@ -134,7 +134,7 @@ func Find(be lister, t Type, prefix string) (ID, error) {
// FindSnapshot takes a string and tries to find a snapshot whose ID matches
// the string as closely as possible.
func FindSnapshot(be lister, s string) (ID, error) {
func FindSnapshot(be Lister, s string) (ID, error) {
// parse ID directly
if id, err := ParseID(s); err == nil {
return id, nil
@ -151,7 +151,7 @@ func FindSnapshot(be lister, s string) (ID, error) {
// PrefixLength returns the number of bytes required so that all prefixes of
// all IDs of type t are unique.
func PrefixLength(be lister, t Type) (int, error) {
func PrefixLength(be Lister, t Type) (int, error) {
// load all IDs of the given type
list, err := be.List(t)
if err != nil {