From 58a1d865a9ee304f9776cef90fe8195c08dad6cc Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sun, 12 Jul 2015 17:58:47 -0700 Subject: [PATCH] Renaming nimble to minhttp --- .../{nimble => minhttp}/LICENSE.Facebook | 0 pkg/server/{nimble => minhttp}/LICENSE.Minio | 0 pkg/server/{nimble => minhttp}/http.go | 10 +++--- pkg/server/{nimble => minhttp}/net.go | 32 +++++++++---------- pkg/server/{nimble => minhttp}/net_test.go | 14 ++++---- pkg/server/server.go | 4 +-- 6 files changed, 30 insertions(+), 30 deletions(-) rename pkg/server/{nimble => minhttp}/LICENSE.Facebook (100%) rename pkg/server/{nimble => minhttp}/LICENSE.Minio (100%) rename pkg/server/{nimble => minhttp}/http.go (94%) rename pkg/server/{nimble => minhttp}/net.go (88%) rename pkg/server/{nimble => minhttp}/net_test.go (94%) diff --git a/pkg/server/nimble/LICENSE.Facebook b/pkg/server/minhttp/LICENSE.Facebook similarity index 100% rename from pkg/server/nimble/LICENSE.Facebook rename to pkg/server/minhttp/LICENSE.Facebook diff --git a/pkg/server/nimble/LICENSE.Minio b/pkg/server/minhttp/LICENSE.Minio similarity index 100% rename from pkg/server/nimble/LICENSE.Minio rename to pkg/server/minhttp/LICENSE.Minio diff --git a/pkg/server/nimble/http.go b/pkg/server/minhttp/http.go similarity index 94% rename from pkg/server/nimble/http.go rename to pkg/server/minhttp/http.go index 0472d3406..57ed99a4d 100644 --- a/pkg/server/nimble/http.go +++ b/pkg/server/minhttp/http.go @@ -14,12 +14,12 @@ * limitations under the License. */ -// Package nimble provides easy to use graceful restart for a set of HTTP services +// Package minhttp provides easy to use graceful restart for a set of HTTP services // -// This package originally from https://github.com/facebookgo/grace +// This package is a fork from https://github.com/facebookgo/grace // // Re-licensing with Apache License 2.0, with code modifications -package nimble +package minhttp import ( "crypto/tls" @@ -40,7 +40,7 @@ type app struct { servers []*http.Server listeners []net.Listener sds []httpdown.Server - net *nimbleNet + net *minNet errors chan error } @@ -128,7 +128,7 @@ func ListenAndServe(servers ...*http.Server) error { servers: servers, listeners: make([]net.Listener, 0, len(servers)), sds: make([]httpdown.Server, 0, len(servers)), - net: &nimbleNet{}, + net: &minNet{}, errors: make(chan error, 1+(len(servers)*2)), } diff --git a/pkg/server/nimble/net.go b/pkg/server/minhttp/net.go similarity index 88% rename from pkg/server/nimble/net.go rename to pkg/server/minhttp/net.go index 65cfc5d48..0bdbe6514 100644 --- a/pkg/server/nimble/net.go +++ b/pkg/server/minhttp/net.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package nimble +package minhttp import ( "fmt" @@ -28,7 +28,7 @@ import ( "github.com/minio/minio/pkg/iodine" ) -// This package originally from https://github.com/facebookgo/grace +// This package is a fork https://github.com/facebookgo/grace // // Re-licensing with Apache License 2.0, with code modifications @@ -50,17 +50,17 @@ const ( // it at startup. var originalWD, _ = os.Getwd() -// nimbleNet provides the family of Listen functions and maintains the associated -// state. Typically you will have only once instance of nimbleNet per application. -type nimbleNet struct { +// minNet provides the family of Listen functions and maintains the associated +// state. Typically you will have only once instance of minNet per application. +type minNet struct { inheritedListeners []net.Listener activeListeners []net.Listener mutex sync.Mutex inheritOnce sync.Once } -// nimbleAddr simple wrapper over net.Addr interface to implement IsEqual() -type nimbleAddr struct { +// minAddr simple wrapper over net.Addr interface to implement IsEqual() +type minAddr struct { net.Addr } @@ -70,7 +70,7 @@ type fileListener interface { } // getInheritedListeners - look for LISTEN_FDS in environment variables and populate listeners accordingly -func (n *nimbleNet) getInheritedListeners() error { +func (n *minNet) getInheritedListeners() error { var retErr error n.inheritOnce.Do(func() { n.mutex.Lock() @@ -108,7 +108,7 @@ func (n *nimbleNet) getInheritedListeners() error { // a stream-oriented network: "tcp", "tcp4", "tcp6", "unix" or "unixpacket". It // returns an inherited net.Listener for the matching network and address, or // creates a new one using net.Listen() -func (n *nimbleNet) Listen(nett, laddr string) (net.Listener, error) { +func (n *minNet) Listen(nett, laddr string) (net.Listener, error) { switch nett { default: return nil, net.UnknownNetworkError(nett) @@ -130,7 +130,7 @@ func (n *nimbleNet) Listen(nett, laddr string) (net.Listener, error) { // ListenTCP announces on the local network address laddr. The network net must // be: "tcp", "tcp4" or "tcp6". It returns an inherited net.Listener for the // matching network and address, or creates a new one using net.ListenTCP. -func (n *nimbleNet) ListenTCP(nett string, laddr *net.TCPAddr) (*net.TCPListener, error) { +func (n *minNet) ListenTCP(nett string, laddr *net.TCPAddr) (*net.TCPListener, error) { if err := n.getInheritedListeners(); err != nil { return nil, iodine.New(err, nil) } @@ -143,7 +143,7 @@ func (n *nimbleNet) ListenTCP(nett string, laddr *net.TCPAddr) (*net.TCPListener if l == nil { // we nil used inherited listeners continue } - equal := nimbleAddr{l.Addr()}.IsEqual(laddr) + equal := minAddr{l.Addr()}.IsEqual(laddr) if equal { n.inheritedListeners[i] = nil n.activeListeners = append(n.activeListeners, l) @@ -163,7 +163,7 @@ func (n *nimbleNet) ListenTCP(nett string, laddr *net.TCPAddr) (*net.TCPListener // ListenUnix announces on the local network address laddr. The network net // must be a: "unix" or "unixpacket". It returns an inherited net.Listener for // the matching network and address, or creates a new one using net.ListenUnix. -func (n *nimbleNet) ListenUnix(nett string, laddr *net.UnixAddr) (*net.UnixListener, error) { +func (n *minNet) ListenUnix(nett string, laddr *net.UnixAddr) (*net.UnixListener, error) { if err := n.getInheritedListeners(); err != nil { return nil, iodine.New(err, nil) } @@ -176,7 +176,7 @@ func (n *nimbleNet) ListenUnix(nett string, laddr *net.UnixAddr) (*net.UnixListe if l == nil { // we nil used inherited listeners continue } - equal := nimbleAddr{l.Addr()}.IsEqual(laddr) + equal := minAddr{l.Addr()}.IsEqual(laddr) if equal { n.inheritedListeners[i] = nil n.activeListeners = append(n.activeListeners, l) @@ -194,7 +194,7 @@ func (n *nimbleNet) ListenUnix(nett string, laddr *net.UnixAddr) (*net.UnixListe } // activeListeners returns a snapshot copy of the active listeners. -func (n *nimbleNet) getActiveListeners() ([]net.Listener, error) { +func (n *minNet) getActiveListeners() ([]net.Listener, error) { n.mutex.Lock() defer n.mutex.Unlock() ls := make([]net.Listener, len(n.activeListeners)) @@ -203,7 +203,7 @@ func (n *nimbleNet) getActiveListeners() ([]net.Listener, error) { } // IsEqual is synonymous with IP.IsEqual() method, here IsEqual matches net.Addr instead of net.IP -func (n1 nimbleAddr) IsEqual(n2 net.Addr) bool { +func (n1 minAddr) IsEqual(n2 net.Addr) bool { if n1.Network() != n2.Network() { return false } @@ -228,7 +228,7 @@ func (n1 nimbleAddr) IsEqual(n2 net.Addr) bool { // arguments as when it was originally started. This allows for a newly // deployed binary to be started. It returns the pid of the newly started // process when successful. -func (n *nimbleNet) StartProcess() (int, error) { +func (n *minNet) StartProcess() (int, error) { listeners, err := n.getActiveListeners() if err != nil { return 0, iodine.New(err, nil) diff --git a/pkg/server/nimble/net_test.go b/pkg/server/minhttp/net_test.go similarity index 94% rename from pkg/server/nimble/net_test.go rename to pkg/server/minhttp/net_test.go index f7757d140..de32afd81 100644 --- a/pkg/server/nimble/net_test.go +++ b/pkg/server/minhttp/net_test.go @@ -14,7 +14,7 @@ * limitations under the License. */ -package nimble +package minhttp import ( "os" @@ -33,19 +33,19 @@ var _ = Suite(&MySuite{}) func (s *MySuite) TestEmptyCountEnvVariable(c *C) { os.Setenv(envCountKey, "") - n := &nimbleNet{} + n := &minNet{} c.Assert(n.getInheritedListeners(), IsNil) } func (s *MySuite) TestZeroCountEnvVariable(c *C) { os.Setenv(envCountKey, "0") - n := &nimbleNet{} + n := &minNet{} c.Assert(n.getInheritedListeners(), IsNil) } func (s *MySuite) TestInvalidCountEnvVariable(c *C) { os.Setenv(envCountKey, "a") - n := &nimbleNet{} + n := &minNet{} expected := regexp.MustCompile("^found invalid count value: LISTEN_FDS=a$") err := n.getInheritedListeners() c.Assert(err, Not(IsNil)) @@ -54,7 +54,7 @@ func (s *MySuite) TestInvalidCountEnvVariable(c *C) { func (s *MySuite) TestInheritErrorOnListenTCPWithInvalidCount(c *C) { os.Setenv(envCountKey, "a") - n := &nimbleNet{} + n := &minNet{} expected := regexp.MustCompile("^found invalid count value: LISTEN_FDS=a$") _, err := n.Listen("tcp", ":0") c.Assert(err, Not(IsNil)) @@ -63,7 +63,7 @@ func (s *MySuite) TestInheritErrorOnListenTCPWithInvalidCount(c *C) { func (s *MySuite) TestInvalidNetwork(c *C) { os.Setenv(envCountKey, "") - n := &nimbleNet{} + n := &minNet{} _, err := n.Listen("foo", "") c.Assert(err, Not(IsNil)) c.Assert(regexp.MustCompile("^unknown network foo$").MatchString(iodine.ToError(err).Error()), Equals, true) @@ -71,7 +71,7 @@ func (s *MySuite) TestInvalidNetwork(c *C) { func (s *MySuite) TestInvalidTcpAddr(c *C) { os.Setenv(envCountKey, "") - n := &nimbleNet{} + n := &minNet{} _, err := n.Listen("tcp", "abc") c.Assert(err, Not(IsNil)) c.Assert(regexp.MustCompile("^missing port in address abc$").MatchString(iodine.ToError(err).Error()), Equals, true) diff --git a/pkg/server/server.go b/pkg/server/server.go index 352e70f4a..b3df6e46c 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -26,7 +26,7 @@ import ( "github.com/minio/minio/pkg/iodine" "github.com/minio/minio/pkg/server/api" - "github.com/minio/minio/pkg/server/nimble" + "github.com/minio/minio/pkg/server/minhttp" ) // getAPI server instance @@ -114,7 +114,7 @@ func StartServices(conf api.Config) error { // start ticket master go startTM(minioAPI) - if err := nimble.ListenAndServe(apiServer, rpcServer); err != nil { + if err := minhttp.ListenAndServe(apiServer, rpcServer); err != nil { return iodine.New(err, nil) } return nil