Merge pull request #39 from fkautz/pr_out_making_in_memory_storage_data_type_private

master
Frederick F. Kautz IV 10 years ago
commit 3a3d9989d1
  1. 18
      pkg/storage/inmemory/inmemory.go

@ -12,7 +12,7 @@ import (
mstorage "github.com/minio-io/minio/pkg/storage" mstorage "github.com/minio-io/minio/pkg/storage"
) )
type Storage struct { type storage struct {
bucketdata map[string]storedBucket bucketdata map[string]storedBucket
objectdata map[string]storedObject objectdata map[string]storedObject
} }
@ -28,7 +28,7 @@ type storedObject struct {
data []byte data []byte
} }
func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) { func (storage *storage) CopyObjectToWriter(w io.Writer, bucket string, object string) (int64, error) {
// TODO synchronize access // TODO synchronize access
// get object // get object
key := bucket + ":" + object key := bucket + ":" + object
@ -41,7 +41,7 @@ func (storage *Storage) CopyObjectToWriter(w io.Writer, bucket string, object st
} }
} }
func (storage *Storage) StoreObject(bucket string, key string, data io.Reader) error { func (storage *storage) StoreObject(bucket string, key string, data io.Reader) error {
objectKey := bucket + ":" + key objectKey := bucket + ":" + key
if _, ok := storage.objectdata[objectKey]; ok == true { if _, ok := storage.objectdata[objectKey]; ok == true {
return mstorage.ObjectExists{Bucket: bucket, Key: key} return mstorage.ObjectExists{Bucket: bucket, Key: key}
@ -63,7 +63,7 @@ func (storage *Storage) StoreObject(bucket string, key string, data io.Reader) e
return nil return nil
} }
func (storage *Storage) StoreBucket(bucketName string) error { func (storage *storage) StoreBucket(bucketName string) error {
if !mstorage.IsValidBucket(bucketName) { if !mstorage.IsValidBucket(bucketName) {
return mstorage.BucketNameInvalid{Bucket: bucketName} return mstorage.BucketNameInvalid{Bucket: bucketName}
} }
@ -81,7 +81,7 @@ func (storage *Storage) StoreBucket(bucketName string) error {
return nil return nil
} }
func (storage *Storage) ListObjects(bucket, prefix string, count int) []mstorage.ObjectMetadata { func (storage *storage) ListObjects(bucket, prefix string, count int) []mstorage.ObjectMetadata {
// TODO prefix and count handling // TODO prefix and count handling
var results []mstorage.ObjectMetadata var results []mstorage.ObjectMetadata
for key, object := range storage.objectdata { for key, object := range storage.objectdata {
@ -92,7 +92,7 @@ func (storage *Storage) ListObjects(bucket, prefix string, count int) []mstorage
return results return results
} }
func (storage *Storage) ListBuckets(prefix string) []mstorage.BucketMetadata { func (storage *storage) ListBuckets(prefix string) []mstorage.BucketMetadata {
// TODO prefix handling // TODO prefix handling
var results []mstorage.BucketMetadata var results []mstorage.BucketMetadata
for _, bucket := range storage.bucketdata { for _, bucket := range storage.bucketdata {
@ -101,11 +101,11 @@ func (storage *Storage) ListBuckets(prefix string) []mstorage.BucketMetadata {
return results return results
} }
func Start() (chan<- string, <-chan error, *Storage) { func Start() (chan<- string, <-chan error, *storage) {
ctrlChannel := make(chan string) ctrlChannel := make(chan string)
errorChannel := make(chan error) errorChannel := make(chan error)
go start(ctrlChannel, errorChannel) go start(ctrlChannel, errorChannel)
return ctrlChannel, errorChannel, &Storage{ return ctrlChannel, errorChannel, &storage{
bucketdata: make(map[string]storedBucket), bucketdata: make(map[string]storedBucket),
objectdata: make(map[string]storedObject), objectdata: make(map[string]storedObject),
} }
@ -115,7 +115,7 @@ func start(ctrlChannel <-chan string, errorChannel chan<- error) {
close(errorChannel) close(errorChannel)
} }
func (storage *Storage) GetObjectMetadata(bucket, key string) mstorage.ObjectMetadata { func (storage *storage) GetObjectMetadata(bucket, key string) mstorage.ObjectMetadata {
objectKey := bucket + ":" + key objectKey := bucket + ":" + key
return storage.objectdata[objectKey].metadata return storage.objectdata[objectKey].metadata

Loading…
Cancel
Save