Rename "Close" to "ShutDown"

This commit is contained in:
Zoltán Papp
2024-08-21 16:17:39 +02:00
parent a208e7999c
commit c1a54756e8
8 changed files with 28 additions and 28 deletions

View File

@@ -7,5 +7,5 @@ import (
type Listener interface {
Listen(func(conn net.Conn)) error
Close(ctx context.Context) error
Shutdown(ctx context.Context) error
}

View File

@@ -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
}

View File

@@ -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{}

View File

@@ -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
}