Trivial NewClientFromURI simplification

This commit is contained in:
Yuce Tekol 2017-10-17 12:07:45 +03:00
parent 48c0dbaee7
commit 0f8f596376
No known key found for this signature in database
GPG key ID: CB59E46D2FB90573
3 changed files with 6 additions and 13 deletions

View file

@ -61,10 +61,11 @@ func NewClient(host string, options *ClientOptions) (*Client, error) {
return nil, err
}
return NewClientFromURI(uri, options)
client := NewClientFromURI(uri, options)
return client, nil
}
func NewClientFromURI(defaultURI *URI, options *ClientOptions) (*Client, error) {
func NewClientFromURI(defaultURI *URI, options *ClientOptions) *Client {
if options == nil {
options = &ClientOptions{}
}
@ -76,7 +77,7 @@ func NewClientFromURI(defaultURI *URI, options *ClientOptions) (*Client, error)
return &Client{
defaultURI: defaultURI,
HTTPClient: client,
}, nil
}
}
// Host returns the host the client was initialized with.

View file

@ -55,12 +55,8 @@ func NewExecutor(clientOptions *ClientOptions) (*Executor, error) {
if clientOptions == nil {
clientOptions = &ClientOptions{}
}
client, err := NewClientFromURI(nil, clientOptions)
if err != nil {
return nil, err
}
return &Executor{
client: client,
client: NewClientFromURI(nil, clientOptions),
}, nil
}

View file

@ -1506,11 +1506,7 @@ func (h *Handler) handlePostFrameRestore(w http.ResponseWriter, r *http.Request)
}
// Create a client for the remote cluster.
client, err := NewClientFromURI(host, h.ClientOptions)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
client := NewClientFromURI(host, h.ClientOptions)
// Determine the maximum number of slices.
maxSlices, err := client.MaxSliceByIndex(r.Context())