Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
having a single method that accepts a pointer and the rest accepting non-pointers seems a bit odd.
we might want to make all of them accept pointer... see GetVersion(), GetClusterVersions() etc.
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 mean that Sync() return the real etcd endpoints? such as:
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.
the methods for
Client
have different signatures:func (c *Client) Sync()
func (c Client) AddMember(name string, peerAddrs string) ([]Member, error) {
...
Sync()
uses a pointer, but the rest of the methods use non-pointers.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.
Sync() only return error now, but the rest of the methods return multi values.
Can change this
Sync()
method return endpoints and error, like other methods?The
NewFromCluster
invokeSync()
like below:In this case, all methods use non-pointers, and only change
Sync()
methods, but test case maybe need to update.The other ways, the methods of
Client
all change non-pointers to pointer, the way need to change more codes.I am not sure if i understand what you mean?If wrong, can you explain your comments again. Thanks.
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.
@pytimer my point is this:
^ see how
c
is a pointer inSync
but not a pointer in the rest of methods for theClient
type.we need to make all the methods consistent.
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.
/hold
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.
@pytimer please kindly fix as discussed above to address @neolit123 feedback and then I will leave hold
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.
@fabriziopandini @neolit123
Fix like:
Is it ok?
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.
@pytimer @fabriziopandini @neolit123 I am not OK with
func (c Client) Sync() ([]string, error)
. This is no longer aSync
method. It's not even aGetEndpoints
method (because we haveEndpoints
member inClient
). Furthermore, this introduces a code smell (inappropriate intimacy), whereNewFromCluster
now updates field insideClient
.This is a lot worse solution to the problem it tries to solve. I am much more in favor of making all methods
func (c *Client)
, than have this. I am also in favor of having onlySync()
take a pointer toClient
.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.
@pytimer
OK, i missed the part that we want to modify the existing Client object and not a copy.
please bring back
(c *Client) Sync()
.we will then cherry pick this PR for 1.13.
and we can have another PR that refactors all methods to use pointers.