-
Notifications
You must be signed in to change notification settings - Fork 542
Description
What problem does your feature solve?
The rpcclient.Client struct stores the RPC URL internally but doesn't expose it:
type Client struct {
url string // unexported
cli *jrpc2.Client
mx sync.RWMutex
httpClient *http.Client
}When wrapping the client in another type, there's no way to retrieve the URL it was configured with. This is useful for debugging, logging, and testing purposes.
For comparison, horizonclient.Client has an exported HorizonURL field that can be accessed directly.
What would you like to see?
Add a URL() method to rpcclient.Client that returns the configured URL:
// URL returns the RPC server URL this client is configured to use.
func (c *Client) URL() string {
return c.url
}What alternatives are there?
-
Store a duplicate copy of the URL - This is what we're currently doing in stellar/friendbot when wrapping the client, but it's redundant since the client already has this information.
-
Export the
urlfield - ChangeurltoURLto make it exported. However, a getter method is preferred as it maintains encapsulation and allows for future flexibility.