mirror of
https://github.com/minio/minio.git
synced 2025-03-03 07:10:07 -05:00
Exposing expiration for memory driver
This commit is contained in:
parent
c01fb92eca
commit
b86b26e7e5
4
Godeps/Godeps.json
generated
4
Godeps/Godeps.json
generated
@ -27,8 +27,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio-io/cli",
|
"ImportPath": "github.com/minio-io/cli",
|
||||||
"Comment": "1.2.0-108-g4ad376c",
|
"Comment": "1.2.0-110-g111d644",
|
||||||
"Rev": "4ad376c97a51a452e36aaa4c19e42560e64be836"
|
"Rev": "111d6445d384505978aaf5b218ce96d163b73c57"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/stretchr/objx",
|
"ImportPath": "github.com/stretchr/objx",
|
||||||
|
2
Godeps/_workspace/src/github.com/minio-io/cli/context.go
generated
vendored
2
Godeps/_workspace/src/github.com/minio-io/cli/context.go
generated
vendored
@ -186,7 +186,7 @@ func (a Args) Last() string {
|
|||||||
|
|
||||||
// Tail - Return the rest of the arguments (not the first one)
|
// Tail - Return the rest of the arguments (not the first one)
|
||||||
// or else an empty string slice
|
// or else an empty string slice
|
||||||
func (a Args) Tail() []string {
|
func (a Args) Tail() Args {
|
||||||
if len(a) >= 2 {
|
if len(a) >= 2 {
|
||||||
return []string(a)[1:]
|
return []string(a)[1:]
|
||||||
}
|
}
|
||||||
|
13
main.go
13
main.go
@ -141,11 +141,22 @@ func runMemory(c *cli.Context) {
|
|||||||
apiServerConfig := getAPIServerConfig(c)
|
apiServerConfig := getAPIServerConfig(c)
|
||||||
maxMemory, err := humanize.ParseBytes(c.Args().First())
|
maxMemory, err := humanize.ParseBytes(c.Args().First())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Fatalf("Invalid memory size [%s] passed. Reason: %s\n", c.Args().First(), err)
|
Fatalf("Invalid memory size [%s] passed. Reason: %s\n", c.Args().First(), iodine.New(err, nil))
|
||||||
|
}
|
||||||
|
tail := c.Args().Tail()
|
||||||
|
var expiration time.Duration
|
||||||
|
if tail.First() != "" {
|
||||||
|
expiration, err = time.ParseDuration(tail.First())
|
||||||
|
if err != nil {
|
||||||
|
Fatalf("Invalid expiration time [%s] passed. Reason: %s\n", tail.First(), iodine.New(err, nil))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expiration = 0
|
||||||
}
|
}
|
||||||
memoryDriver := server.MemoryFactory{
|
memoryDriver := server.MemoryFactory{
|
||||||
Config: apiServerConfig,
|
Config: apiServerConfig,
|
||||||
MaxMemory: maxMemory,
|
MaxMemory: maxMemory,
|
||||||
|
Expiration: expiration,
|
||||||
}
|
}
|
||||||
apiServer := memoryDriver.GetStartServerFunc()
|
apiServer := memoryDriver.GetStartServerFunc()
|
||||||
webServer := getWebServerConfigFunc(c)
|
webServer := getWebServerConfigFunc(c)
|
||||||
|
@ -35,12 +35,13 @@ import (
|
|||||||
type MemoryFactory struct {
|
type MemoryFactory struct {
|
||||||
httpserver.Config
|
httpserver.Config
|
||||||
MaxMemory uint64
|
MaxMemory uint64
|
||||||
|
Expiration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStartServerFunc builds memory api servers
|
// GetStartServerFunc builds memory api servers
|
||||||
func (f MemoryFactory) GetStartServerFunc() StartServerFunc {
|
func (f MemoryFactory) GetStartServerFunc() StartServerFunc {
|
||||||
return func() (chan<- string, <-chan error) {
|
return func() (chan<- string, <-chan error) {
|
||||||
_, _, driver := memory.Start(f.MaxMemory, 1*time.Hour)
|
_, _, driver := memory.Start(f.MaxMemory, f.Expiration)
|
||||||
//ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config)
|
//ctrl, status, _ := httpserver.Start(api.HTTPHandler(f.Domain, driver), f.Config)
|
||||||
ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config)
|
ctrl, status, _ := httpserver.Start(api.HTTPHandler("", driver), f.Config)
|
||||||
return ctrl, status
|
return ctrl, status
|
||||||
|
Loading…
x
Reference in New Issue
Block a user