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:
ginuerzh
2026-05-24 16:00:53 +08:00
parent 419f4c4c73
commit 011759d888
7 changed files with 1992 additions and 14 deletions
+12
View File
@@ -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
}