-
Notifications
You must be signed in to change notification settings - Fork 721
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
*: add config client #2041
*: add config client #2041
Conversation
b88c677
to
ccd1729
Compare
Codecov Report
@@ Coverage Diff @@
## master #2041 +/- ##
=========================================
+ Coverage 76.72% 76.83% +0.1%
=========================================
Files 191 193 +2
Lines 19293 19414 +121
=========================================
+ Hits 14803 14916 +113
Misses 3369 3369
- Partials 1121 1129 +8
Continue to review full report at Codecov.
|
ccd1729
to
4abf1bc
Compare
client/config_client.go
Outdated
return errors.WithStack(errFailInitClusterID) | ||
} | ||
|
||
func (c *configClient) updateLeader() 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.
Maybe we add it to PD client so we don't have to manage connections in both places.
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.
@overvenus PTAL
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
e2b8f51
to
62dc5ea
Compare
PTAL @disksing @overvenus |
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.
Rest LGTM
client/base_client.go
Outdated
) | ||
|
||
// BaseClient is a basic client for all other complex client. | ||
type BaseClient struct { |
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.
type BaseClient struct { | |
type baseClient struct { |
If BaseClient
is only for internal use, I think it's better to not export it for better maintainability.
client/base_client.go
Outdated
} | ||
|
||
// NewBaseClient returns a new BaseClient. | ||
func NewBaseClient(ctx context.Context, urls []string, security SecurityOption, opts ...ClientOption) *BaseClient { |
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.
func NewBaseClient(ctx context.Context, urls []string, security SecurityOption, opts ...ClientOption) *BaseClient { | |
func newBaseClient(ctx context.Context, urls []string, security SecurityOption, opts ...ClientOption) *BaseClient { |
mergeAndUpdateConfig(localCfg, updateEntries) | ||
if wrongEntry, err := mergeAndUpdateConfig(localCfg, updateEntries); err != nil { | ||
c.deleteEntry(component, wrongEntry) | ||
|
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.
remove empty line.
client/config_client.go
Outdated
log.Info("[pd] init cluster id", zap.Uint64("cluster-id", c.clusterID)) | ||
|
||
c.wg.Add(1) | ||
go c.leaderLoop() |
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.
can we move this to baseclient?
client/config_client.go
Outdated
log.Info("[pd] create pd configuration client with endpoints", zap.Strings("pd-address", pdAddrs)) | ||
base := NewBaseClient(ctx, addrsToUrls(pdAddrs), security) | ||
c := &configClient{base} | ||
c.connMu.clientConns = make(map[string]*grpc.ClientConn) |
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.
seems already created in baseClient.
client/config_client.go
Outdated
if err := c.initRetry(c.initClusterID); err != nil { | ||
return nil, err | ||
} | ||
if err := c.initRetry(c.updateLeader); err != nil { |
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 do it in baseClient
/run-all-tests |
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.
Rest LGTM
@@ -117,45 +113,13 @@ var ( | |||
) | |||
|
|||
type client struct { | |||
urls []string | |||
clusterID uint64 | |||
*baseClient |
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 adding a function in Client
that we can generate a ConfigClient
from Client
. TiDB
may want to only use one client or one connection.
04d68d4
to
d475550
Compare
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
/merge |
/run-all-tests |
What problem does this PR solve?
Part of #1977. It should be reviewed after #2033 is merged.
What is changed and how it works?
This PR adds a client for config manager service.
Check List
Tests