mirror of https://github.com/minio/minio.git
Merge pull request #324 from fkautz/pr_out_adding_interfaces_for_donut_driver
This commit is contained in:
commit
7ddf6a9f8f
|
@ -0,0 +1,45 @@
|
|||
package donut
|
||||
|
||||
import "io"
|
||||
|
||||
// INTERFACES
|
||||
|
||||
// Donut interface
|
||||
type Donut interface {
|
||||
CreateBucket(bucket string) error
|
||||
GetBuckets() ([]string, error)
|
||||
GetObject(bucket, object string) (io.ReadCloser, error)
|
||||
GetObjectMetadata(bucket, object string) (map[string]string, error)
|
||||
GetObjectWriter(bucket, object string) (ObjectWriter, error)
|
||||
}
|
||||
|
||||
// Bucket is an interface for managing buckets
|
||||
type Bucket interface {
|
||||
GetObject(object string) (io.Reader, error)
|
||||
GetObjectMetadata(object string) (map[string]string, error)
|
||||
GetObjectWriter(object string) (ObjectWriter, error)
|
||||
GetObjects() ([]string, error)
|
||||
}
|
||||
|
||||
// Disk is an interface for managing disks
|
||||
type Disk interface {
|
||||
GetBuckets(object string) ([]string, error)
|
||||
}
|
||||
|
||||
// ObjectWriter is an interface for writing new objects
|
||||
type ObjectWriter interface {
|
||||
Write([]byte) error
|
||||
Close() error
|
||||
CloseWithError(error) error
|
||||
|
||||
SetMetadata(map[string]string)
|
||||
GetMetadata() map[string]string
|
||||
}
|
||||
|
||||
// InternalObjectWriter is an interface for use internally to donut
|
||||
type InternalObjectWriter interface {
|
||||
ObjectWriter
|
||||
|
||||
SetDonutMetadata(map[string]string)
|
||||
GetDonutMetadata() map[string]string
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package donut
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
)
|
||||
|
||||
type donutDriver struct {
|
||||
buckets map[string]Bucket
|
||||
disks map[string]Disk
|
||||
}
|
||||
|
||||
// NewDonutDriver instantiates a donut driver for use in object storage
|
||||
func NewDonutDriver() Donut {
|
||||
return donutDriver{
|
||||
buckets: make(map[string]Bucket),
|
||||
disks: make(map[string]Disk),
|
||||
}
|
||||
}
|
||||
|
||||
func notImplemented() error {
|
||||
return errors.New("Not Implemented")
|
||||
}
|
||||
|
||||
// CreateBucket creates a bucket
|
||||
func (driver donutDriver) CreateBucket(bucket string) error {
|
||||
return notImplemented()
|
||||
}
|
||||
|
||||
// GetBuckets returns a list of buckets
|
||||
func (driver donutDriver) GetBuckets() ([]string, error) {
|
||||
return nil, notImplemented()
|
||||
}
|
||||
|
||||
// GetObject returns an object
|
||||
func (driver donutDriver) GetObject(bucket, object string) (io.ReadCloser, error) {
|
||||
return nil, notImplemented()
|
||||
}
|
||||
|
||||
// GetObjectMetadata returns object metadata
|
||||
func (driver donutDriver) GetObjectMetadata(bucket, object string) (map[string]string, error) {
|
||||
return nil, notImplemented()
|
||||
}
|
||||
|
||||
// GetObjectWriter returns a writer for creating a new object.
|
||||
func (driver donutDriver) GetObjectWriter(bucket, object string) (ObjectWriter, error) {
|
||||
return nil, notImplemented()
|
||||
}
|
Loading…
Reference in New Issue