Merge pull request #94 from fkautz/pr_out_refactoring_file_storage_driver_to_fsstorage

master
Frederick F. Kautz IV 10 years ago
commit c2917f0d64
  1. 4
      pkgs/gateway/gateway.go
  2. 8
      pkgs/storage/fsstorage/fs_storage.go
  3. 4
      pkgs/storage/fsstorage/fs_storage_test.go
  4. 14
      pkgs/storage/storage.go
  5. 7
      pkgs/storage/storage_test.go

@ -8,7 +8,7 @@ import (
"path"
"github.com/gorilla/mux"
"github.com/minio-io/minio/pkgs/storage"
"github.com/minio-io/minio/pkgs/storage/fsstorage"
"github.com/tchap/go-patricia/patricia"
)
@ -197,7 +197,7 @@ func InMemoryStorageDriver(bucket string, input chan ObjectRequest, config Gatew
}
func SimpleFileStorageDriver(bucket string, input chan ObjectRequest, config GatewayConfig) {
fileStorage := storage.FileStorage{
fileStorage := fsstorage.FileSystemStorage{
RootDir: config.dataDir,
}
for request := range input {

@ -1,4 +1,4 @@
package storage
package fsstorage
import (
"io/ioutil"
@ -7,16 +7,16 @@ import (
"path/filepath"
)
type FileStorage struct {
type FileSystemStorage struct {
RootDir string
}
func (storage FileStorage) Get(objectPath string) ([]byte, error) {
func (storage FileSystemStorage) Get(objectPath string) ([]byte, error) {
return ioutil.ReadFile(path.Join(storage.RootDir, objectPath))
}
func (storage FileStorage) Put(objectPath string, object []byte) error {
func (storage FileSystemStorage) Put(objectPath string, object []byte) error {
os.MkdirAll(filepath.Dir(path.Join(storage.RootDir, objectPath)), 0700)
return ioutil.WriteFile(path.Join(storage.RootDir, objectPath), object, 0600)
}

@ -1,4 +1,4 @@
package storage
package fsstorage
import (
. "gopkg.in/check.v1"
@ -6,7 +6,7 @@ import (
"os"
)
type FileStorageSuite struct{}
type FileSystemStorageSuite struct{}
var _ = Suite(&FileStorageSuite{})

@ -1,20 +1,6 @@
package storage
import (
"fmt"
"github.com/gorilla/mux"
"net/http"
)
type ObjectStorage interface {
Get(path string) ([]byte, error)
Put(path string, object []byte) error
}
func RegisterStorageHandlers(router *mux.Router) {
router.HandleFunc("/storage/rpc", StorageHandler)
}
func StorageHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Storage")
}

@ -1,6 +1,7 @@
package storage
import (
"fmt"
"io/ioutil"
"log"
"net/http"
@ -9,7 +10,7 @@ import (
)
func TestPrintsStorage(t *testing.T) {
server := httptest.NewServer(http.HandlerFunc(StorageHandler))
server := httptest.NewServer(http.HandlerFunc(storageHandler))
defer server.Close()
res, err := http.Get(server.URL)
if err != nil {
@ -25,3 +26,7 @@ func TestPrintsStorage(t *testing.T) {
log.Fatal("Expected 'Storage', Received '" + bodyString + "'")
}
}
func storageHandler(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Storage")
}

Loading…
Cancel
Save