-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Implement endpoint watch and resolver #12669
Implement endpoint watch and resolver #12669
Conversation
for _, kv := range resp.Kvs { | ||
var iup internal.Update | ||
if err := json.Unmarshal(kv.Value, &iup); err != nil { | ||
continue |
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 worth logging the error at least (as WARNING with the 'corrupted' key)
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.
Should the logger(*zap.Logger
) be created internally or passed from outside?
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.
Good question.
- I assumed clientv3.lg, but this one is private.
- logger.go is practically dead - I will prepare PR to delete this one.
So there are 2 options:
- Expose the public c.Logger() getter and use it.
- Expand signature of NewManager to take the logger parameter.
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. Let's go for 1. It's in scope of the same 'library' and it's hard to imagine use-case when user want's to have separate logger for endpoint resolution.
Please comment that this method is for internal use of etcd-client library and should not be used as general-purpose logger.
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
if err == nil { | ||
up := &Update{Op: op, Key: string(e.Kv.Key), Endpoint: Endpoint{Addr: iup.Addr, Metadata: iup.Metadata}} | ||
deltaUps = append(deltaUps, up) | ||
} |
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.
else {
log...
}
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.
Thank you. That looks really good.
Let's wait for other maintainers feedback/suggestions e.g. ad. logger.
for _, kv := range resp.Kvs { | ||
var iup internal.Update | ||
if err := json.Unmarshal(kv.Value, &iup); err != nil { | ||
continue |
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.
Good question.
- I assumed clientv3.lg, but this one is private.
- logger.go is practically dead - I will prepare PR to delete this one.
So there are 2 options:
- Expose the public c.Logger() getter and use it.
- Expand signature of NewManager to take the logger parameter.
4cd5b27
to
b07886c
Compare
@@ -110,7 +110,6 @@ func TestEtcdGrpcResolver(t *testing.T) { | |||
} | |||
t.Fatalf("unexpected response from foo (e2): %s", resp.GetPayload().GetBody()) | |||
} | |||
|
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.
FYI:
git commit -amend
git push --force
Is usual "hack" to re-trigger 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.
Thanks!
05812c2
to
a542896
Compare
8bd48ed
to
8feb55f
Compare
Thank you |
…opy change Signed-off-by: Nate W <4453979+nate-double-u@users.noreply.github.com>
@@ -112,7 +113,7 @@ func New(cfg Config) (*Client, error) { | |||
// service interface implementations and do not need connection management. | |||
func NewCtxClient(ctx context.Context) *Client { | |||
cctx, cancel := context.WithCancel(ctx) | |||
return &Client{ctx: cctx, cancel: cancel, lg: zap.NewNop()} | |||
return &Client{ctx: cctx, cancel: cancel, lgMu: new(sync.RWMutex), lg: zap.NewNop()} |
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.
@chaochn47 It seems that you missed this change in the second commit in #16800?
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 for capturing that!
Zero value of RWMutex
should be the same new(sync.RWMutext)
though.
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.
Zero value of RWMutex should be the same new(sync.RWMutext) though.
It isn't true. zero value for a pointer is nil, while the result of new(sync.RWMutext)
isn't 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.
You are right.
Fix #12652
@peterbourgon