removed usage code (for later)
This commit is contained in:
parent
f7cf3c26e6
commit
0d3fa3d88b
|
@ -10,7 +10,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"slices"
|
"slices"
|
||||||
"sync"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,10 +19,6 @@ type (
|
||||||
RpcUrl string
|
RpcUrl string
|
||||||
HttpTimeout time.Duration
|
HttpTimeout time.Duration
|
||||||
logger *zap.SugaredLogger
|
logger *zap.SugaredLogger
|
||||||
|
|
||||||
// for grindiness tracking
|
|
||||||
usage int64
|
|
||||||
mu sync.RWMutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Request struct {
|
Request struct {
|
||||||
|
@ -54,18 +49,6 @@ func NewRPCClient(rpcAddr string, httpTimeout time.Duration) *Client {
|
||||||
return &Client{HttpClient: http.Client{}, RpcUrl: rpcAddr, HttpTimeout: httpTimeout, logger: slog.Get()}
|
return &Client{HttpClient: http.Client{}, RpcUrl: rpcAddr, HttpTimeout: httpTimeout, logger: slog.Get()}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) addUsage(usage int64) {
|
|
||||||
c.mu.Lock()
|
|
||||||
defer c.mu.Unlock()
|
|
||||||
c.usage += usage
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *Client) GetUsage() int64 {
|
|
||||||
c.mu.RLock()
|
|
||||||
defer c.mu.RUnlock()
|
|
||||||
return c.usage
|
|
||||||
}
|
|
||||||
|
|
||||||
func getResponse[T any](
|
func getResponse[T any](
|
||||||
ctx context.Context, client *Client, method string, params []any, rpcResponse *Response[T],
|
ctx context.Context, client *Client, method string, params []any, rpcResponse *Response[T],
|
||||||
) error {
|
) error {
|
||||||
|
@ -98,8 +81,7 @@ func getResponse[T any](
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error processing %s rpc call: %w", method, err)
|
return fmt.Errorf("error processing %s rpc call: %w", method, err)
|
||||||
}
|
}
|
||||||
// add usage + debug log response:
|
// debug log response:
|
||||||
client.addUsage(int64(len(body)))
|
|
||||||
logger.Debugf("%s response: %v", method, string(body))
|
logger.Debugf("%s response: %v", method, string(body))
|
||||||
|
|
||||||
// unmarshal the response into the predicted format
|
// unmarshal the response into the predicted format
|
||||||
|
|
Loading…
Reference in New Issue