2015-03-18 17:27:10 -04:00
|
|
|
package donut
|
|
|
|
|
2015-03-23 23:06:15 -04:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
)
|
2015-03-18 17:27:10 -04:00
|
|
|
|
|
|
|
// INTERFACES
|
|
|
|
|
|
|
|
// Donut interface
|
|
|
|
type Donut interface {
|
|
|
|
CreateBucket(bucket string) error
|
2015-03-22 03:39:39 -04:00
|
|
|
GetObject(bucket, object string) (io.ReadCloser, error)
|
2015-03-22 15:36:51 -04:00
|
|
|
GetObjectMetadata(bucket, object string) (map[string]string, error)
|
2015-03-22 18:33:52 -04:00
|
|
|
GetObjectWriter(bucket, object string) (ObjectWriter, error)
|
|
|
|
ListBuckets() ([]string, error)
|
|
|
|
ListObjects(bucket string) ([]string, error)
|
2015-03-18 17:27:10 -04:00
|
|
|
}
|
|
|
|
|
2015-03-22 03:39:39 -04:00
|
|
|
// Bucket interface
|
2015-03-18 17:27:10 -04:00
|
|
|
type Bucket interface {
|
2015-03-22 03:39:39 -04:00
|
|
|
GetNodes() ([]string, error)
|
2015-03-18 17:27:10 -04:00
|
|
|
}
|
|
|
|
|
2015-03-22 05:53:21 -04:00
|
|
|
// Node interface
|
2015-03-22 03:39:39 -04:00
|
|
|
type Node interface {
|
2015-03-23 23:06:15 -04:00
|
|
|
CreateBucket(bucket string) error
|
2015-03-22 03:39:39 -04:00
|
|
|
GetBuckets() ([]string, error)
|
|
|
|
GetDonutMetadata(bucket, object string) (map[string]string, error)
|
2015-03-22 18:33:52 -04:00
|
|
|
GetMetadata(bucket, object string) (map[string]string, error)
|
|
|
|
GetReader(bucket, object string) (io.ReadCloser, error)
|
|
|
|
GetWriter(bucket, object string) (Writer, error)
|
|
|
|
ListObjects(bucket string) ([]string, error)
|
2015-03-18 17:27:10 -04:00
|
|
|
}
|
|
|
|
|
2015-03-22 03:39:39 -04:00
|
|
|
// ObjectWriter interface
|
2015-03-18 17:27:10 -04:00
|
|
|
type ObjectWriter interface {
|
|
|
|
Close() error
|
|
|
|
CloseWithError(error) error
|
2015-03-22 03:39:39 -04:00
|
|
|
GetMetadata() (map[string]string, error)
|
2015-03-22 18:33:52 -04:00
|
|
|
SetMetadata(map[string]string) error
|
|
|
|
Write([]byte) (int, error)
|
2015-03-18 17:27:10 -04:00
|
|
|
}
|
|
|
|
|
2015-03-22 05:53:21 -04:00
|
|
|
// Writer interface
|
|
|
|
type Writer interface {
|
2015-03-18 17:27:10 -04:00
|
|
|
ObjectWriter
|
|
|
|
|
2015-03-22 03:39:39 -04:00
|
|
|
GetDonutMetadata() (map[string]string, error)
|
|
|
|
SetDonutMetadata(map[string]string) error
|
2015-03-18 17:27:10 -04:00
|
|
|
}
|