-
Notifications
You must be signed in to change notification settings - Fork 3
validator: implement client stub to interatct with proxy server #3
Conversation
Signed-off-by: disksing <[email protected]>
} | ||
|
||
// Scan queries continuous kv pairs in range [startKey, endKey), up to limit pairs. | ||
func (c *RawClientStub) Scan(startKey, endKey []byte, limit int) ([][]byte, [][]byte, 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.
Do we also need ReverseScan
?
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.
Yes. Plan to do it when resolving #6
client: http.Client{Timeout: time.Second * 10}, | ||
proxyServer: strings.TrimSuffix(proxyServer, "/"), | ||
} | ||
res, err := client.send("/rawkv/client/new", &RawRequest{PDAddrs: pdServers}) |
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.
How about using a prefix variable?
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 think this way is more readable to understand the format of the URI.
|
||
// Close closes the client and releases resources in proxy server. | ||
func (c *RawClientStub) Close() error { | ||
_, err := c.send(fmt.Sprintf("/rawkv/client/%s/close", c.id), &RawRequest{}) |
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.
maybe we can directly use +
here?
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 think this way is more readable to understand the format of the URI.
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.
fmt.Sprintf
relies on the reflection which is not elegant I think.
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.
Why reflection is not elegant... For the validator, performance is not important, what matters is correctness and readability.
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.
ok
Signed-off-by: disksing <[email protected]>
The client stub will look like a RawKVClient / TxnKVClient, but internally send messages to the proxy server.
Signed-off-by: disksing [email protected]