-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New advanced client #82
Conversation
Make client aware of the state of all cluster nodes. Add topology discovery requests. Add healthcheks. Add primary/secondary request routing. Add round-robin endpoint selector for reads. Add pluggable request retriers. Add pluggable backoff retrying policies. Add pluggable read preference option. Refactor client configuration.
@@ -114,7 +114,7 @@ func TestQueryConsistencyProof(t *testing.T) { | |||
balloon, err := NewBalloon(store, hashing.NewFakeXorHasher) | |||
require.NoError(t, err) | |||
|
|||
for j := 0; j <= int(c.addtions); j++ { | |||
for j := 0; j <= int(c.additions); j++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks... 🤕
// The number of retries is set to 0. | ||
func NewSimpleHTTPClient(httpClient *http.Client, urls []string) (*HTTPClient, error) { | ||
|
||
// defaultTransport := http.DefaultTransport.(*http.Transport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup
} | ||
|
||
// DefaultConfig creates a Config structures with default values. | ||
func DefaultConfig() *Config { | ||
return &Config{ | ||
Endpoints: []string{"127.0.0.1:8800"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything should be defaulted in the same place, so maybe we need to create DefaultEndpoints and DefaultApiKeys?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The client's constructor also uses the default values. Note that, now, you can construct the client with a conf or with options.
Dial: (&net.Dialer{ | ||
Timeout: conf.DialTimeout, | ||
}).Dial, | ||
Proxy: defaultTransport.Proxy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultTransport is already a copy of http.DefaultTansport (since the struct is complex) so instead of reinstantiate a new http.Transport we can configure it.
... and all the defaults remain (and also futurible new params)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something like...
transport := http.DefaultTransport.(*http.Transport)
transport.Dial = (&net.Dialer{
Timeout: conf.DialTimeout,
}).Dial
options = append(options, SetHttpClient(&http.Client{
Timeout: conf.Timeout,
Transport: transport, })
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to get rid of most of these transport options in a future refactoring. Anyway, thanks for the tip...
"github.com/bbva/qed/log" | ||
) | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it should be a const.
@@ -68,12 +70,22 @@ func NewMonitor(conf Config) (*Monitor, error) { | |||
// Metrics | |||
metrics.QedMonitorInstancesCount.Inc() | |||
|
|||
// QED client | |||
transport := http.DefaultTransport.(*http.Transport) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this 😄 is what I was meaning in client/options.go:53 comment
Also NewHTTPClientFromConfig seems overkill since it's only used twice
|
The client is also intended to be used outside QED project. I prefer to make the client's construction more flexible. |
|
||
// NextReadendpoint returns the next available endpoint to query | ||
// in a round-robin manner, or ErrNoEndpoint | ||
func (t *topology) NextReadEndpoint(pref ReadPref) (*endpoint, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method should probably be simplified on a future revision of the client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGETM, we will need to clean / simplify things in future revisions
New advanced client Former-commit-id: f594e71
No description provided.