docs(hosts,hop): add doc comments, fix missing httpLoader.Close, accumulate reload errors
- hosts/hosts.go: add package and symbol doc comments, fix missing httpLoader.Close() in Close() - hosts/plugin: add doc comments for HTTP and gRPC plugin types - hop/hop.go: add doc comments, accumulate reload/parse errors via errors.Join instead of silently discarding them - hop/plugin/http.go: add doc comments and missing Close() method - Add unit tests for hosts (580 lines) and hop (991 lines)
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/go-gost/core/chain"
|
||||
@@ -115,3 +116,14 @@ func (p *httpPlugin) Select(ctx context.Context, opts ...hop.SelectOption) *chai
|
||||
}
|
||||
return node
|
||||
}
|
||||
|
||||
func (p *httpPlugin) Close() error {
|
||||
if p.client == nil {
|
||||
return nil
|
||||
}
|
||||
p.client.CloseIdleConnections()
|
||||
if tr, ok := p.client.Transport.(io.Closer); ok {
|
||||
return tr.Close()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user