refactor(various): Listner -> Listener readability improvements (#3672)

* refactor(net_timeout): `listner` -> `listener`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(s3): `s3ApiLocalListner` -> `s3ApiLocalListener`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(filer): `localPublicListner` -> `localPublicListener`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(command): `masterLocalListner` -> `masterLocalListener`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

* refactor(net_timeout): `ipListner` -> `ipListener`

Signed-off-by: Ryan Russell <git@ryanrussell.org>

Signed-off-by: Ryan Russell <git@ryanrussell.org>
This commit is contained in:
Ryan Russell 2022-09-14 13:59:55 -05:00 committed by GitHub
parent a8d7615eec
commit 8efe1db01a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 25 deletions

View file

@ -250,7 +250,7 @@ func (fo *FilerOptions) startFiler() {
if *fo.publicPort != 0 { if *fo.publicPort != 0 {
publicListeningAddress := util.JoinHostPort(*fo.bindIp, *fo.publicPort) publicListeningAddress := util.JoinHostPort(*fo.bindIp, *fo.publicPort)
glog.V(0).Infoln("Start Seaweed filer server", util.Version(), "public at", publicListeningAddress) glog.V(0).Infoln("Start Seaweed filer server", util.Version(), "public at", publicListeningAddress)
publicListener, localPublicListner, e := util.NewIpAndLocalListeners(*fo.bindIp, *fo.publicPort, 0) publicListener, localPublicListener, e := util.NewIpAndLocalListeners(*fo.bindIp, *fo.publicPort, 0)
if e != nil { if e != nil {
glog.Fatalf("Filer server public listener error on port %d:%v", *fo.publicPort, e) glog.Fatalf("Filer server public listener error on port %d:%v", *fo.publicPort, e)
} }
@ -259,9 +259,9 @@ func (fo *FilerOptions) startFiler() {
glog.Fatalf("Volume server fail to serve public: %v", e) glog.Fatalf("Volume server fail to serve public: %v", e)
} }
}() }()
if localPublicListner != nil { if localPublicListener != nil {
go func() { go func() {
if e := http.Serve(localPublicListner, publicVolumeMux); e != nil { if e := http.Serve(localPublicListener, publicVolumeMux); e != nil {
glog.Errorf("Volume server fail to serve public: %v", e) glog.Errorf("Volume server fail to serve public: %v", e)
} }
}() }()

View file

@ -146,7 +146,7 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList), masterPeers) ms := weed_server.NewMasterServer(r, masterOption.toMasterOption(masterWhiteList), masterPeers)
listeningAddress := util.JoinHostPort(*masterOption.ipBind, *masterOption.port) listeningAddress := util.JoinHostPort(*masterOption.ipBind, *masterOption.port)
glog.V(0).Infof("Start Seaweed Master %s at %s", util.Version(), listeningAddress) glog.V(0).Infof("Start Seaweed Master %s at %s", util.Version(), listeningAddress)
masterListener, masterLocalListner, e := util.NewIpAndLocalListeners(*masterOption.ipBind, *masterOption.port, 0) masterListener, masterLocalListener, e := util.NewIpAndLocalListeners(*masterOption.ipBind, *masterOption.port, 0)
if e != nil { if e != nil {
glog.Fatalf("Master startup error: %v", e) glog.Fatalf("Master startup error: %v", e)
} }
@ -239,8 +239,8 @@ func startMaster(masterOption MasterOptions, masterWhiteList []string) {
} }
httpS := &http.Server{Handler: r} httpS := &http.Server{Handler: r}
if masterLocalListner != nil { if masterLocalListener != nil {
go httpS.Serve(masterLocalListner) go httpS.Serve(masterLocalListener)
} }
if useMTLS { if useMTLS {

View file

@ -120,7 +120,7 @@ func startMasterFollower(masterOptions MasterOptions) {
ms := weed_server.NewMasterServer(r, option, masters) ms := weed_server.NewMasterServer(r, option, masters)
listeningAddress := util.JoinHostPort(*masterOptions.ipBind, *masterOptions.port) listeningAddress := util.JoinHostPort(*masterOptions.ipBind, *masterOptions.port)
glog.V(0).Infof("Start Seaweed Master %s at %s", util.Version(), listeningAddress) glog.V(0).Infof("Start Seaweed Master %s at %s", util.Version(), listeningAddress)
masterListener, masterLocalListner, e := util.NewIpAndLocalListeners(*masterOptions.ipBind, *masterOptions.port, 0) masterListener, masterLocalListener, e := util.NewIpAndLocalListeners(*masterOptions.ipBind, *masterOptions.port, 0)
if e != nil { if e != nil {
glog.Fatalf("Master startup error: %v", e) glog.Fatalf("Master startup error: %v", e)
} }
@ -144,8 +144,8 @@ func startMasterFollower(masterOptions MasterOptions) {
// start http server // start http server
httpS := &http.Server{Handler: r} httpS := &http.Server{Handler: r}
if masterLocalListner != nil { if masterLocalListener != nil {
go httpS.Serve(masterLocalListner) go httpS.Serve(masterLocalListener)
} }
go httpS.Serve(masterListener) go httpS.Serve(masterListener)

View file

@ -215,7 +215,7 @@ func (s3opt *S3Options) startS3Server() bool {
} }
listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port) listenAddress := fmt.Sprintf("%s:%d", *s3opt.bindIp, *s3opt.port)
s3ApiListener, s3ApiLocalListner, err := util.NewIpAndLocalListeners(*s3opt.bindIp, *s3opt.port, time.Duration(10)*time.Second) s3ApiListener, s3ApiLocalListener, err := util.NewIpAndLocalListeners(*s3opt.bindIp, *s3opt.port, time.Duration(10)*time.Second)
if err != nil { if err != nil {
glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err) glog.Fatalf("S3 API Server listener on %s error: %v", listenAddress, err)
} }
@ -243,9 +243,9 @@ func (s3opt *S3Options) startS3Server() bool {
if *s3opt.tlsPrivateKey != "" { if *s3opt.tlsPrivateKey != "" {
glog.V(0).Infof("Start Seaweed S3 API Server %s at https port %d", util.Version(), *s3opt.port) glog.V(0).Infof("Start Seaweed S3 API Server %s at https port %d", util.Version(), *s3opt.port)
if s3ApiLocalListner != nil { if s3ApiLocalListener != nil {
go func() { go func() {
if err = httpS.ServeTLS(s3ApiLocalListner, *s3opt.tlsCertificate, *s3opt.tlsPrivateKey); err != nil { if err = httpS.ServeTLS(s3ApiLocalListener, *s3opt.tlsCertificate, *s3opt.tlsPrivateKey); err != nil {
glog.Fatalf("S3 API Server Fail to serve: %v", err) glog.Fatalf("S3 API Server Fail to serve: %v", err)
} }
}() }()
@ -255,9 +255,9 @@ func (s3opt *S3Options) startS3Server() bool {
} }
} else { } else {
glog.V(0).Infof("Start Seaweed S3 API Server %s at http port %d", util.Version(), *s3opt.port) glog.V(0).Infof("Start Seaweed S3 API Server %s at http port %d", util.Version(), *s3opt.port)
if s3ApiLocalListner != nil { if s3ApiLocalListener != nil {
go func() { go func() {
if err = httpS.Serve(s3ApiLocalListner); err != nil { if err = httpS.Serve(s3ApiLocalListener); err != nil {
glog.Fatalf("S3 API Server Fail to serve: %v", err) glog.Fatalf("S3 API Server Fail to serve: %v", err)
} }
}() }()

View file

@ -83,14 +83,14 @@ func (c *Conn) Close() error {
return err return err
} }
func NewListener(addr string, timeout time.Duration) (ipListner net.Listener, err error) { func NewListener(addr string, timeout time.Duration) (ipListener net.Listener, err error) {
listner, err := net.Listen("tcp", addr) listener, err := net.Listen("tcp", addr)
if err != nil { if err != nil {
return return
} }
ipListner = &Listener{ ipListener = &Listener{
Listener: listner, Listener: listener,
ReadTimeout: timeout, ReadTimeout: timeout,
WriteTimeout: timeout, WriteTimeout: timeout,
} }
@ -98,27 +98,27 @@ func NewListener(addr string, timeout time.Duration) (ipListner net.Listener, er
return return
} }
func NewIpAndLocalListeners(host string, port int, timeout time.Duration) (ipListner net.Listener, localListener net.Listener, err error) { func NewIpAndLocalListeners(host string, port int, timeout time.Duration) (ipListener net.Listener, localListener net.Listener, err error) {
listner, err := net.Listen("tcp", JoinHostPort(host, port)) listener, err := net.Listen("tcp", JoinHostPort(host, port))
if err != nil { if err != nil {
return return
} }
ipListner = &Listener{ ipListener = &Listener{
Listener: listner, Listener: listener,
ReadTimeout: timeout, ReadTimeout: timeout,
WriteTimeout: timeout, WriteTimeout: timeout,
} }
if host != "localhost" && host != "" && host != "0.0.0.0" && host != "127.0.0.1" && host != "[::]" && host != "[::1]" { if host != "localhost" && host != "" && host != "0.0.0.0" && host != "127.0.0.1" && host != "[::]" && host != "[::1]" {
listner, err = net.Listen("tcp", JoinHostPort("localhost", port)) listener, err = net.Listen("tcp", JoinHostPort("localhost", port))
if err != nil { if err != nil {
glog.V(0).Infof("skip starting on %s:%d: %v", host, port, err) glog.V(0).Infof("skip starting on %s:%d: %v", host, port, err)
return ipListner, nil, nil return ipListener, nil, nil
} }
localListener = &Listener{ localListener = &Listener{
Listener: listner, Listener: listener,
ReadTimeout: timeout, ReadTimeout: timeout,
WriteTimeout: timeout, WriteTimeout: timeout,
} }