Use errorChannels only for services not for drivers, reduce them to use simple functions

This commit is contained in:
Harshavardhana
2015-06-28 23:53:53 -07:00
parent b2bf90afbd
commit 42c0287943
9 changed files with 44 additions and 59 deletions

View File

@@ -29,22 +29,14 @@ type fsDriver struct {
multiparts *Multiparts
}
// Start filesystem channel
func Start(root string) (chan<- string, <-chan error, drivers.Driver) {
ctrlChannel := make(chan string)
errorChannel := make(chan error)
// NewDriver instantiate a new filesystem driver
func NewDriver(root string) (drivers.Driver, error) {
fs := new(fsDriver)
fs.root = root
fs.lock = new(sync.Mutex)
// internal related to multiparts
fs.multiparts = new(Multiparts)
fs.multiparts.ActiveSession = make(map[string]*MultipartSession)
go start(ctrlChannel, errorChannel, fs)
return ctrlChannel, errorChannel, fs
}
func start(ctrlChannel <-chan string, errorChannel chan<- error, fs *fsDriver) {
err := os.MkdirAll(fs.root, 0700)
errorChannel <- err
close(errorChannel)
return fs, err
}

View File

@@ -38,7 +38,8 @@ func (s *MySuite) TestAPISuite(c *C) {
path, err := ioutil.TempDir(os.TempDir(), "minio-fs-")
c.Check(err, IsNil)
storageList = append(storageList, path)
_, _, store := Start(path)
store, err := NewDriver(path)
c.Check(err, IsNil)
return store
}
drivers.APITestSuite(c, create)