Merge pull request #828 from harshavardhana/controller-consolidation

Consolidate controller, move rpc package into controller - remove dan…
This commit is contained in:
Harshavardhana 2015-09-15 19:41:21 -07:00
commit c7fe91de49
13 changed files with 9 additions and 36 deletions

View file

@ -42,7 +42,7 @@ func controllerMain(c *cli.Context) {
if c.Args().Present() {
cli.ShowCommandHelpAndExit(c, "controller", 1)
}
err := controller.StartController()
err := controller.Start()
if err != nil {
Fatalln(err)
}

View file

@ -20,7 +20,7 @@ import (
"net/http"
router "github.com/gorilla/mux"
"github.com/minio/minio/pkg/rpc"
"github.com/minio/minio/pkg/controller/rpc"
)
// getRPCHandler rpc handler

View file

@ -22,7 +22,7 @@ import (
"testing"
jsonrpc "github.com/gorilla/rpc/v2/json"
"github.com/minio/minio/pkg/rpc"
"github.com/minio/minio/pkg/controller/rpc"
. "gopkg.in/check.v1"
)

View file

@ -54,7 +54,8 @@ func getRPCServer(rpcHandler http.Handler) (*http.Server, *probe.Error) {
return httpServer, nil
}
func StartController() *probe.Error {
// Start starts a controller
func Start() *probe.Error {
rpcServer, err := getRPCServer(getRPCHandler())
if err != nil {
return err.Trace()

View file

@ -20,7 +20,6 @@ import (
"net/http"
router "github.com/gorilla/mux"
"github.com/minio/minio/pkg/rpc"
"github.com/minio/minio/pkg/server/api"
)
@ -72,17 +71,3 @@ func getAPIHandler(conf api.Config) (http.Handler, api.Minio) {
apiHandler := registerCustomMiddleware(mux, mwHandlers...)
return apiHandler, minioAPI
}
// getRPCHandler rpc handler
func getRPCHandler() http.Handler {
s := rpc.NewServer()
s.RegisterJSONCodec()
// Add new RPC services here
return registerRPC(router.NewRouter(), s)
}
// registerRPC - register rpc handlers
func registerRPC(mux *router.Router, s *rpc.Server) http.Handler {
mux.Handle("/rpc", s)
return mux
}

View file

@ -83,17 +83,6 @@ func getAPIServer(conf api.Config, apiHandler http.Handler) (*http.Server, *prob
return httpServer, nil
}
// getRPCServer instance
func getRPCServer(rpcHandler http.Handler) *http.Server {
// Minio server config
httpServer := &http.Server{
Addr: ":9001", // TODO make this configurable
Handler: rpcHandler,
MaxHeaderBytes: 1 << 20,
}
return httpServer
}
// Start ticket master
func startTM(a api.Minio) {
for {
@ -103,18 +92,16 @@ func startTM(a api.Minio) {
}
}
// StartServices starts basic services for a server
func StartServices(conf api.Config) *probe.Error {
// Start starts a s3 compatible cloud storage server
func Start(conf api.Config) *probe.Error {
apiHandler, minioAPI := getAPIHandler(conf)
apiServer, err := getAPIServer(conf, apiHandler)
if err != nil {
return err.Trace()
}
rpcServer := getRPCServer(getRPCHandler())
// start ticket master
go startTM(minioAPI)
if err := minhttp.ListenAndServeLimited(conf.RateLimit, apiServer, rpcServer); err != nil {
if err := minhttp.ListenAndServeLimited(conf.RateLimit, apiServer); err != nil {
return err.Trace()
}
return nil

View file

@ -60,7 +60,7 @@ func serverMain(c *cli.Context) {
cli.ShowCommandHelpAndExit(c, "server", 1)
}
apiServerConfig := getServerConfig(c)
if err := server.StartServices(apiServerConfig); err != nil {
if err := server.Start(apiServerConfig); err != nil {
Fatalln(err.Trace())
}
}