mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-26 04:06:38 +00:00
Rename "Close" to "ShutDown"
This commit is contained in:
@@ -7,5 +7,5 @@ import (
|
||||
|
||||
type Listener interface {
|
||||
Listen(func(conn net.Conn)) error
|
||||
Close(ctx context.Context) error
|
||||
Shutdown(ctx context.Context) error
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ func (l *Listener) Listen(acceptFn func(conn net.Conn)) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (l *Listener) Close(ctx context.Context) error {
|
||||
func (l *Listener) Shutdown(ctx context.Context) error {
|
||||
if l.server == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -101,9 +101,9 @@ func (r *Relay) Accept(conn net.Conn) {
|
||||
}()
|
||||
}
|
||||
|
||||
// Close closes the relay server
|
||||
// Shutdown closes the relay server
|
||||
// It closes the connection with all peers in gracefully and stops accepting new connections.
|
||||
func (r *Relay) Close(ctx context.Context) {
|
||||
func (r *Relay) Shutdown(ctx context.Context) {
|
||||
log.Infof("close connection with all peers")
|
||||
r.closeMu.Lock()
|
||||
wg := sync.WaitGroup{}
|
||||
|
||||
@@ -58,15 +58,15 @@ func (r *Server) Listen(cfg ListenerConfig) error {
|
||||
return wslErr
|
||||
}
|
||||
|
||||
// Close stops the relay server. If there are active connections, they will be closed gracefully. In case of a timeout,
|
||||
// Shutdown stops the relay server. If there are active connections, they will be closed gracefully. In case of a context,
|
||||
// the connections will be forcefully closed.
|
||||
func (r *Server) Close(ctx context.Context) (err error) {
|
||||
func (r *Server) Shutdown(ctx context.Context) (err error) {
|
||||
// stop service new connections
|
||||
if r.wSListener != nil {
|
||||
err = r.wSListener.Close(ctx)
|
||||
err = r.wSListener.Shutdown(ctx)
|
||||
}
|
||||
|
||||
r.relay.Close(ctx)
|
||||
r.relay.Shutdown(ctx)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user