From 05a5c6d710efaf76d19e6eafe3921941e2b15a08 Mon Sep 17 00:00:00 2001 From: Matt Johnstone Date: Tue, 11 Jun 2024 20:11:12 +0200 Subject: [PATCH] reverted NewSolanaCollector name + more of Jeff's nits --- .gitignore | 6 ++++++ cmd/solana_exporter/exporter.go | 4 ++-- pkg/rpc/client.go | 7 ++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index e69de29..008ebbb 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,6 @@ +# for prometheus configs: +.prometheus + +# builds: +.builds +solana_exporter \ No newline at end of file diff --git a/cmd/solana_exporter/exporter.go b/cmd/solana_exporter/exporter.go index ce9afd8..344920b 100644 --- a/cmd/solana_exporter/exporter.go +++ b/cmd/solana_exporter/exporter.go @@ -35,7 +35,7 @@ type solanaCollector struct { solanaVersion *prometheus.Desc } -func newSolanaCollector(rpcAddr string) *solanaCollector { +func NewSolanaCollector(rpcAddr string) *solanaCollector { return &solanaCollector{ rpcClient: rpc.NewRPCClient(rpcAddr), totalValidatorsDesc: prometheus.NewDesc( @@ -132,7 +132,7 @@ func main() { httpTimeout = time.Duration(*httpTimeoutSecs) * time.Second - collector := newSolanaCollector(*rpcAddr) + collector := NewSolanaCollector(*rpcAddr) go collector.WatchSlots() diff --git a/pkg/rpc/client.go b/pkg/rpc/client.go index fc0d178..d860b6c 100644 --- a/pkg/rpc/client.go +++ b/pkg/rpc/client.go @@ -87,11 +87,8 @@ func (c *Client) rpcRequest(ctx context.Context, data io.Reader) ([]byte, error) if err != nil { return nil, err } - defer func() { - if err := resp.Body.Close(); err != nil { - klog.Errorf("could not close response body: %v", err) - } - }() + //goland:noinspection GoUnhandledErrorResult + defer resp.Body.Close() body, err := io.ReadAll(resp.Body) if err != nil {