8000 store: refactor GetRemote by tmrts · Pull Request #2975 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

store: refactor GetRemote #2975

Merged
merged 2 commits into from
Sep 15, 2016
Merged

store: refactor GetRemote #2975

merged 2 commits into from
Sep 15, 2016

Conversation

tmrts
Copy link
Contributor
@tmrts tmrts commented Jul 25, 2016

Removes the 2nd argument signalling whether the remote is found or not
and returns a distinct error instead.

cc @lucab @sgotti

@tmrts tmrts mentioned this pull request Jul 25, 2016
@tmrts tmrts force-pushed the refactor/store branch 9 times, most recently from f0b7948 to b061cd0 Compare July 25, 2016 13:44
"time"
)

var (
ErrRemoteNotFound = errors.New("remote with the given ACI URL not found")
Copy link
Member

Choose a reason for hiding this comment

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

Given that we are already planning to integrate non-ACI stores, can we remove ACI references from there? A generic remote target not found should suffice.

Copy link
Contributor
@sgotti sgotti Jul 25, 2016

Choose a reason for hiding this comment

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

Just a personal taste, but I find easier to just return nil if not found and check it in the caller instead of the error type checking. Many pkgs (with the exception of os that wraps a syscall error for ErrNotFound) do this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

8000

I don't agree with returning nil to check whether a function succeeded or failed. We already have an error field in the function signature

Copy link
Contributor

Choose a reason for hiding this comment

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

@tmrts @lucab No problem, that's fine!

Copy link
Contributor

Choose a reason for hiding this comment

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

I changed my mind 😄 . And to keep a common pattern, when possible, in #3071 I started using the same ErrNotFound approach.

@lucab
Copy link
Member
lucab commented Jul 25, 2016

This is in line with what we discussed and looks fine, just one minor comment inline. Let's give a chance to @sgotti to have a look before merging it, as I think he's already touching this code.

@@ -48,23 +53,26 @@ func remoteRowScan(rows *sql.Rows, remote *Remote) error {

// GetRemote tries to retrieve a remote with the given aciURL. found will be
// false if remote doesn't exist.
func GetRemote(tx *sql.Tx, aciURL string) (remote *Remote, found bool, err error) {
remote = &Remote{}
func GetRemote(tx *sql.Tx, aciURL string) (*Remote, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Godoc needs to be fixed with the new NotFound type (nil or error, see above comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@tmrts
Copy link
Contributor Author
tmrts commented Aug 3, 2016

comments are addressed, PTAL

@lucab
Copy link
Member
lucab commented Aug 4, 2016

Low priority, moved to next milestone while waiting for last review.

@lucab lucab modified the milestones: v1.13.0, v1.12.0 Aug 4, 2016
@lucab
Copy link
Member
lucab commented Aug 17, 2016

@sgotti are you fine with this?

@sgotti
Copy link
Contributor
sgotti commented Aug 17, 2016

After squashing the two commits it LGTM.

@tmrts
Copy link
Contributor Author
tmrts commented Aug 18, 2016

@sgotti commits are independent now, PTAL (2nd commit is a minor cleanup commit of the codebase)

@sgotti
Copy link
Contributor
sgotti commented Aug 18, 2016

@tmrts Thanks! LGTM.

@@ -551,15 +551,21 @@ func (s *Store) RemoveACI(key string) error {

// GetRemote tries to retrieve a remote with the given ACIURL. found will be
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs an update.

@jonboulle jonboulle modified the milestones: 1.14.0, v1.13.0 Aug 18, 2016
@s-urbaniak
Copy link
Contributor

@tmrts up for fixing the nit?

@lucab lucab modified the milestones: v1.15.0, v1.14.0 Aug 31, 2016
tmrts added 2 commits August 31, 2016 17:43
Removes the 2nd argument signalling whether the remote is found or not
and returns a distinct error instead.
@tmrts
Copy link
Contributor Author
tmrts commented Aug 31, 2016

@s-urbaniak sorry I've missed @jonboulle 's comment, PTAL

@s-urbaniak
Copy link
Contributor

lgtm, thanks!

@s-urbaniak s-urbaniak merged commit ce996da into rkt:master Sep 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0