Skip to content
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

Merged

Conversation

lemonlinger
Copy link

@lemonlinger lemonlinger commented Feb 5, 2021

@lemonlinger lemonlinger closed this Feb 5, 2021
@lemonlinger lemonlinger reopened this Feb 5, 2021
for _, kv := range resp.Kvs {
var iup internal.Update
if err := json.Unmarshal(kv.Value, &iup); err != nil {
continue
Copy link
Contributor

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)

Copy link
Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.

  1. I assumed clientv3.lg, but this one is private.
  2. logger.go is practically dead - I will prepare PR to delete this one.

So there are 2 options:

  1. Expose the public c.Logger() getter and use it.
  2. Expand signature of NewManager to take the logger parameter.

@gyuho @jingyih @jpbetz -> do you have opinion here ?

Copy link
Contributor

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.

Copy link
Author

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else {
log...
}

Copy link
Contributor

@ptabor ptabor left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.

  1. I assumed clientv3.lg, but this one is private.
  2. logger.go is practically dead - I will prepare PR to delete this one.

So there are 2 options:

  1. Expose the public c.Logger() getter and use it.
  2. Expand signature of NewManager to take the logger parameter.

@gyuho @jingyih @jpbetz -> do you have opinion here ?

client/v3/naming/resolver/resolver.go Show resolved Hide resolved
@lemonlinger lemonlinger force-pushed the implement-endpoint-manager-and-resolver branch from 4cd5b27 to b07886c Compare February 5, 2021 15:04
@@ -110,7 +110,6 @@ func TestEtcdGrpcResolver(t *testing.T) {
}
t.Fatalf("unexpected response from foo (e2): %s", resp.GetPayload().GetBody())
}

Copy link
Contributor

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lemonlinger lemonlinger force-pushed the implement-endpoint-manager-and-resolver branch from 05812c2 to a542896 Compare February 8, 2021 10:18
@lemonlinger lemonlinger force-pushed the implement-endpoint-manager-and-resolver branch from 8bd48ed to 8feb55f Compare February 8, 2021 12:06
@ptabor ptabor merged commit 3fddea9 into etcd-io:master Feb 8, 2021
@ptabor
Copy link
Contributor

ptabor commented Feb 8, 2021

Thank you

@lemonlinger lemonlinger deleted the implement-endpoint-manager-and-resolver branch February 8, 2021 14:38
nate-double-u added a commit to nate-double-u/etcd-io-website that referenced this pull request Feb 8, 2021
…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()}
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

grpc bump: Implement master/client/v3/naming new endpointManager & resolver
4 participants