mirror of
https://github.com/minio/minio.git
synced 2026-11-22 15:13:48 +00:00
Move memory code out, add it as layer on top of existing donut code
Just like how http.Handlers can be overlayed on top of each other with each implementing ServeHTTP(). drivers.Driver can be overlayed on top of each other in similar manner which would implement the drivers.Driver interface. API <----> cache <----> donut <----> donut(format)
This commit is contained in:
1 parent
fe3c618cc7
commit
8f61d6b6be
9 files changed
+192
-667
No files matched your search
+18
-8
@@ -26,6 +26,8 @@ import (
|
||||
"github.com/minio/minio/pkg/api/web"
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
"github.com/minio/minio/pkg/server/httpserver"
|
||||
"github.com/minio/minio/pkg/storage/drivers"
|
||||
"github.com/minio/minio/pkg/storage/drivers/cache"
|
||||
"github.com/minio/minio/pkg/storage/drivers/donut"
|
||||
"github.com/minio/minio/pkg/utils/log"
|
||||
)
|
||||
@@ -43,22 +45,30 @@ func (f WebFactory) GetStartServerFunc() StartServerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// DonutFactory is used to build donut api server
|
||||
type DonutFactory struct {
|
||||
// Factory is used to build api server
|
||||
type Factory struct {
|
||||
httpserver.Config
|
||||
Paths []string
|
||||
MaxMemory uint64
|
||||
Expiration time.Duration
|
||||
}
|
||||
|
||||
// GetStartServerFunc DonutFactory builds donut api server
|
||||
func (f DonutFactory) GetStartServerFunc() StartServerFunc {
|
||||
// GetStartServerFunc Factory builds api server
|
||||
func (f Factory) GetStartServerFunc() StartServerFunc {
|
||||
return func() (chan<- string, <-chan error) {
|
||||
driver, err := donut.NewDriver(f.Paths, f.MaxMemory, f.Expiration)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
conf := api.Config{RateLimit: f.RateLimit}
|
||||
var driver drivers.Driver
|
||||
var err error
|
||||
if len(f.Paths) != 0 {
|
||||
driver, err = donut.NewDriver(f.Paths)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
driver, err = cache.NewDriver(f.MaxMemory, f.Expiration, driver)
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
}
|
||||
conf.SetDriver(driver)
|
||||
ctrl, status, _ := httpserver.Start(api.HTTPHandler(conf), f.Config)
|
||||
return ctrl, status
|
||||
|
||||
Reference in new issue
Block a user