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

Feat/client features #266

Merged
merged 4 commits into from
Dec 8, 2017
Merged

Feat/client features #266

merged 4 commits into from
Dec 8, 2017

Conversation

hsanjuan
Copy link
Collaborator

@hsanjuan hsanjuan commented Dec 8, 2017

  • Auto-resolve dns multiaddresses
  • Support Host/Port as strings in the config
  • Return regular errors from methods

This is easier in many cases and does not make the user
parse a multiaddress.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
We had a problem happening when assigning the returned *api.Error
to default 'error' type.

Things like "if err != nil" would not work even when *api.Error is nil
I'm not sure why this happens, but this is very confusing for the user
integrating on top. It is better that we just return plain go errors.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
@hsanjuan hsanjuan self-assigned this Dec 8, 2017
@hsanjuan hsanjuan requested a review from ZenGround0 December 8, 2017 14:48
@ghost ghost added the status/in-progress In progress label Dec 8, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.3%) to 70.388% when pulling 4f69606 on feat/client_features into 146e867 on master.

Copy link
Collaborator

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

I'm curious what codeclimate saw wrong with all your tests and have one double check for you regarding madns resolution.

resolveCtx, cancel := context.WithTimeout(ctx, cfg.Timeout)
defer cancel()
resolved, err := madns.Resolve(resolveCtx, cfg.APIAddr)
cfg.APIAddr = resolved[0]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just double checking that the first element of resolved is what we want here. Looking at madns I found that the first element in the case of an ipv4 address is the ip4maddr from: ip4maddr, err := ma.NewMultiaddr("/ip4/" + ip4.String()). I had trouble tracking down what ip4 exactly is from the code but was suspicious this might just be an ip and not include a transport. Maybe that is fine too? Just bringing up because that wouldn't match with the default multiaddr (ip + tcp addrs).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I guess you saw:

		ip4maddr, err := ma.NewMultiaddr("/ip4/" + ip4.String())
		if err != nil {
			return result, err
		}
               parts := append([]ma.Multiaddr{ip4maddr}, encap...)
               result = append(result, ma.Join(parts...))

See it does ma.Join on the result, so the resulting multiaddress has all the parts after the "/ip4/ip", including the /tcp/port etc..

Copy link
Collaborator

@ZenGround0 ZenGround0 Dec 8, 2017

Choose a reason for hiding this comment

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

Ah I was thrown off thinking result already has something else in it, thanks this makes sense

if err != nil {
t.Fatal(err)
}
if c.urlPrefix != "http://127.0.0.1:1234" {
t.Error("bad resolved address")
}
}

func TestVersion(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why did these tests make codeclimate unhappy? Are we planning to replace them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, i forgot to add the file, i moved them

@hsanjuan
Copy link
Collaborator Author

hsanjuan commented Dec 8, 2017

Code climate complained about function length, complexity, fake duplicates... I'm adjusting the settings, somethings are better fixed, others are not so realistic.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
@hsanjuan hsanjuan force-pushed the feat/client_features branch from 4f69606 to d6bb5bb Compare December 8, 2017 16:05
@hsanjuan
Copy link
Collaborator Author

hsanjuan commented Dec 8, 2017

@ZenGround0 added the missing file

Copy link
Collaborator

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

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

LGTM

@hsanjuan hsanjuan merged commit 2fa54ff into master Dec 8, 2017
@ghost ghost removed the status/in-progress In progress label Dec 8, 2017
@hsanjuan hsanjuan deleted the feat/client_features branch December 8, 2017 16:28
@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 72.817% when pulling d6bb5bb on feat/client_features into 146e867 on master.

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

Successfully merging this pull request may close these issues.

3 participants