Skip to content
This repository was archived by the owner on Aug 28, 2021. It is now read-only.

validator: implement client stub to interatct with proxy server #3

Merged
merged 3 commits into from
Apr 25, 2019

Conversation

disksing
Copy link
Collaborator

The client stub will look like a RawKVClient / TxnKVClient, but internally send messages to the proxy server.

Signed-off-by: disksing [email protected]

@disksing disksing requested review from siddontang and rleungx April 11, 2019 09:49
This was referenced Apr 11, 2019
}

// 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) {
Copy link
Member

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?

Copy link
Collaborator Author

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})
Copy link
Member

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?

Copy link
Collaborator Author

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{})
Copy link
Member

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?

Copy link
Collaborator Author

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.

Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Member

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]>
@disksing disksing requested a review from rleungx April 25, 2019 08:45
@disksing disksing merged commit 89f9bd1 into tikv:master Apr 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants