Migrate from iodine to probe

This commit is contained in:
Harshavardhana
2015-08-03 16:17:21 -07:00
parent 7f13095260
commit d09fd8b0a1
38 changed files with 917 additions and 1339 deletions

View File

@@ -20,7 +20,7 @@ import (
"net/http"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/iodine"
"github.com/minio/minio/pkg/probe"
)
// AuthService auth service
@@ -32,15 +32,15 @@ type AuthReply struct {
SecretAccessKey string `json:"secretaccesskey"`
}
func getAuth(reply *AuthReply) error {
func getAuth(reply *AuthReply) *probe.Error {
accessID, err := auth.GenerateAccessKeyID()
if err != nil {
return iodine.New(err, nil)
return err.Trace()
}
reply.AccessKeyID = string(accessID)
secretID, err := auth.GenerateSecretAccessKey()
if err != nil {
return iodine.New(err, nil)
return err.Trace()
}
reply.SecretAccessKey = string(secretID)
return nil
@@ -48,5 +48,8 @@ func getAuth(reply *AuthReply) error {
// Get auth keys
func (s *AuthService) Get(r *http.Request, args *Args, reply *AuthReply) error {
return getAuth(reply)
if err := getAuth(reply); err != nil {
return err
}
return nil
}

View File

@@ -20,7 +20,7 @@ import (
"net/http"
"github.com/minio/minio/pkg/donut"
"github.com/minio/minio/pkg/iodine"
"github.com/minio/minio/pkg/probe"
)
// DonutService donut service
@@ -40,14 +40,14 @@ type Reply struct {
Error error `json:"error"`
}
func setDonut(args *DonutArgs, reply *Reply) error {
func setDonut(args *DonutArgs, reply *Reply) *probe.Error {
conf := &donut.Config{Version: "0.0.1"}
conf.DonutName = args.Name
conf.MaxSize = args.MaxSize
conf.NodeDiskMap = make(map[string][]string)
conf.NodeDiskMap[args.Hostname] = args.Disks
if err := donut.SaveConfig(conf); err != nil {
return iodine.New(err, nil)
return err.Trace()
}
reply.Message = "success"
reply.Error = nil

View File

@@ -21,7 +21,7 @@ import (
"os"
"runtime"
"github.com/minio/minio/pkg/iodine"
"github.com/minio/minio/pkg/probe"
)
// SysInfoService -
@@ -45,7 +45,7 @@ type MemStatsReply struct {
runtime.MemStats `json:"memstats"`
}
func setSysInfoReply(sis *SysInfoReply) error {
func setSysInfoReply(sis *SysInfoReply) *probe.Error {
sis.SysARCH = runtime.GOARCH
sis.SysOS = runtime.GOOS
sis.SysCPUS = runtime.NumCPU()
@@ -55,12 +55,12 @@ func setSysInfoReply(sis *SysInfoReply) error {
var err error
sis.Hostname, err = os.Hostname()
if err != nil {
return iodine.New(err, nil)
return probe.New(err)
}
return nil
}
func setMemStatsReply(sis *MemStatsReply) error {
func setMemStatsReply(sis *MemStatsReply) *probe.Error {
var memStats runtime.MemStats
runtime.ReadMemStats(&memStats)
sis.MemStats = memStats
@@ -69,10 +69,16 @@ func setMemStatsReply(sis *MemStatsReply) error {
// Get method
func (s *SysInfoService) Get(r *http.Request, args *Args, reply *SysInfoReply) error {
return setSysInfoReply(reply)
if err := setSysInfoReply(reply); err != nil {
return err
}
return nil
}
// Get method
func (s *MemStatsService) Get(r *http.Request, args *Args, reply *MemStatsReply) error {
return setMemStatsReply(reply)
if err := setMemStatsReply(reply); err != nil {
return err
}
return nil
}