Consolidate controller, move rpc package into controller - remove dangling code in pkg/server

master
Harshavardhana 9 years ago
parent 8d5f6e0b96
commit 3f4b98ca4c
  1. 2
      controller-main.go
  2. 2
      pkg/controller/router.go
  3. 0
      pkg/controller/rpc/auth.go
  4. 0
      pkg/controller/rpc/donut.go
  5. 0
      pkg/controller/rpc/request.go
  6. 0
      pkg/controller/rpc/server.go
  7. 0
      pkg/controller/rpc/sysinfo.go
  8. 0
      pkg/controller/rpc/version.go
  9. 2
      pkg/controller/rpc_test.go
  10. 3
      pkg/controller/server.go
  11. 15
      pkg/server/router.go
  12. 19
      pkg/server/server.go
  13. 2
      server-main.go

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

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

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

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

@ -20,7 +20,6 @@ import (
"net/http" "net/http"
router "github.com/gorilla/mux" router "github.com/gorilla/mux"
"github.com/minio/minio/pkg/rpc"
"github.com/minio/minio/pkg/server/api" "github.com/minio/minio/pkg/server/api"
) )
@ -72,17 +71,3 @@ func getAPIHandler(conf api.Config) (http.Handler, api.Minio) {
apiHandler := registerCustomMiddleware(mux, mwHandlers...) apiHandler := registerCustomMiddleware(mux, mwHandlers...)
return apiHandler, minioAPI 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
}

@ -83,17 +83,6 @@ func getAPIServer(conf api.Config, apiHandler http.Handler) (*http.Server, *prob
return httpServer, nil 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 // Start ticket master
func startTM(a api.Minio) { func startTM(a api.Minio) {
for { for {
@ -103,18 +92,16 @@ func startTM(a api.Minio) {
} }
} }
// StartServices starts basic services for a server // Start starts a s3 compatible cloud storage server
func StartServices(conf api.Config) *probe.Error { func Start(conf api.Config) *probe.Error {
apiHandler, minioAPI := getAPIHandler(conf) apiHandler, minioAPI := getAPIHandler(conf)
apiServer, err := getAPIServer(conf, apiHandler) apiServer, err := getAPIServer(conf, apiHandler)
if err != nil { if err != nil {
return err.Trace() return err.Trace()
} }
rpcServer := getRPCServer(getRPCHandler())
// start ticket master // start ticket master
go startTM(minioAPI) go startTM(minioAPI)
if err := minhttp.ListenAndServeLimited(conf.RateLimit, apiServer); err != nil {
if err := minhttp.ListenAndServeLimited(conf.RateLimit, apiServer, rpcServer); err != nil {
return err.Trace() return err.Trace()
} }
return nil return nil

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

Loading…
Cancel
Save