Skip to content

Commit

Permalink
Extract method.
Browse files Browse the repository at this point in the history
  • Loading branch information
mdwhatcott committed Jun 20, 2024
1 parent d0f615b commit e713d4b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func newListener(config configuration) ListenCloser {
}

func (this *linkedListener) Listen() {
if this.next == nil {
if this.isLast() {
this.listen()
} else {
go this.listen()
Expand All @@ -56,14 +56,16 @@ func (this *linkedListener) listen() {
closeListener(this.next) // current just completed, now cause the next in line to conclude (if one exists)
}
func (this *linkedListener) onListenComplete() {
if this.next != nil {
if !this.isLast() {
return
}

CloseResources(this.managed...) // after the last/inner-most resource is closed, close these managed resources
CloseResources(this.managed...)
this.managed = this.managed[0:0]
this.logger.Printf("[INFO] All listeners have concluded.")
}
func (this *linkedListener) isLast() bool {
return this.next == nil
}

func (this *linkedListener) Close() error {
defer this.shutdown()
Expand Down

0 comments on commit e713d4b

Please sign in to comment.