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

Adds general options and missing options for table request #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mkasner
Copy link

@mkasner mkasner commented Sep 16, 2019

No description provided.

@codecov-io
Copy link

codecov-io commented Sep 16, 2019

Codecov Report

Merging #13 into master will increase coverage by 0.27%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
+ Coverage   96.55%   96.82%   +0.27%     
==========================================
  Files           8        8              
  Lines         232      252      +20     
==========================================
+ Hits          224      244      +20     
  Misses          4        4              
  Partials        4        4
Impacted Files Coverage Δ
nearest.go 100% <100%> (ø) ⬆️
match.go 100% <100%> (ø) ⬆️
types.go 96.55% <100%> (+0.25%) ⬆️
route.go 100% <100%> (ø) ⬆️
options.go 100% <100%> (ø) ⬆️
table.go 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 788b384...7fc54cc. Read the comment docs.

match.go Show resolved Hide resolved
options.go Outdated Show resolved Hide resolved
table.go Outdated Show resolved Hide resolved
types.go Outdated Show resolved Hide resolved
@mkasner
Copy link
Author

mkasner commented Sep 17, 2019

Updated code with proposed changes

@mkasner mkasner force-pushed the master branch 2 times, most recently from 4e40b18 to 955d9aa Compare September 18, 2019 14:20
Copy link
Contributor

@regeda regeda left a comment

Choose a reason for hiding this comment

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

First of all, great job to make types reusable in different requests.
I have a question: how to be with backward compatibility?
My code does the following:

req := osrm.MatchRequest{
   Hints: []string{"X","Y"},
}

but new change will break compilation process because I need to change the code:

req := osrm.MatchRequest{
    GeneralOptions: osrm.GeneralOptions{
         Hints: []string{"X","Y"},
    },
}

types.go Outdated

const (
FallbackCoordinateInput FallbackCoordinate = "input"
FallbackCoordinateSnapped = "snapped"
Copy link
Contributor

Choose a reason for hiding this comment

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

FallbackCoordinateSnapped FallbackCoordinate as well

Copy link
Author

Choose a reason for hiding this comment

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

Yes, you are right.
I used this like iota :)

Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't work like iota. You must declare the type explicitly.
https://play.golang.org/p/iVeaitEtA2k

AnnotationsDatasources Annotations = "datasources"
AnnotationsWeight Annotations = "weight"
AnnotationsSpeed Annotations = "speed"
AnnotationsDurationDistance Annotations = "duration,distance"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need that?
Maybe add a function to combine multiple annotations in a request?

Copy link
Author

Choose a reason for hiding this comment

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

I can do the function. There's a request in TabeService which combines duration and distance, and returns it in the response. That's the reason I need it.
I thought this would be more simpler, since this is considered like a 3rd option for that param in request.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could add a function:

func (a Annotations) Concat(b Annotations) Annotations {
    return a + "," + b
}

and use it in your code as well:

AnnotationsDuration.Concat(AnnotationsDistance)

Copy link
Author

Choose a reason for hiding this comment

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

I was thinking, if I add a function which enables to combine multiple annotations, then users of the library can product invalid annotations which cannot be combined.
By defining it like this user is always going to produce valid annotations.
This 'duration,distance' is the only combination in the project osrm docs.
I would create a function, if there were more combinations possible, but since it's only one, I would rather leave it defined as const.

@mkasner
Copy link
Author

mkasner commented Sep 20, 2019

First of all, great job to make types reusable in different requests.
I have a question: how to be with backward compatibility?
My code does the following:

req := osrm.MatchRequest{
   Hints: []string{"X","Y"},
}

but new change will break compilation process because I need to change the code:

req := osrm.MatchRequest{
    GeneralOptions: osrm.GeneralOptions{
         Hints: []string{"X","Y"},
    },
}

Yes, this cannot be backward compatible, unless I copy params from the embedded struct GeneralOptions to every request.
I thought this was cleaner approach from the standpoint of library, but it is a breaking change in terms of clients using this library.
You as a reviewer, must be the judge of that.
If you don't want to introduce breaking change, then don't approve this PR, so I can create another one with repeated fields in every request.

@regeda
Copy link
Contributor

regeda commented Sep 20, 2019

First of all, great job to make types reusable in different requests.
I have a question: how to be with backward compatibility?
My code does the following:

req := osrm.MatchRequest{
   Hints: []string{"X","Y"},
}

but new change will break compilation process because I need to change the code:

req := osrm.MatchRequest{
    GeneralOptions: osrm.GeneralOptions{
         Hints: []string{"X","Y"},
    },
}

Yes, this cannot be backward compatible, unless I copy params from the embedded struct GeneralOptions to every request.
I thought this was cleaner approach from the standpoint of library, but it is a breaking change in terms of clients using this library.
You as a reviewer, must be the judge of that.
If you don't want to introduce breaking change, then don't approve this PR, so I can create another one with repeated fields in every request.

I like that PR. But I think maintainers must release a major version of it (for example, v0.2.0) with a notice about the backward-incompatible change.

@mkasner
Copy link
Author

mkasner commented Sep 20, 2019

that PR. But I think maintainers must release a major version of it (for example, v0.2.0) with a notice about the backward-incompatible change.

I didn't yet added changes you requested, about constants type naming, and function for combining duration and distance

types.go Outdated

const (
FallbackCoordinateInput FallbackCoordinate = "input"
FallbackCoordinateSnapped = "snapped"
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't work like iota. You must declare the type explicitly.
https://play.golang.org/p/iVeaitEtA2k

@mkasner
Copy link
Author

mkasner commented Sep 20, 2019

Sure, I know that.
I said, that I used it like iota by mistake.
I'm going to push that change now.

types.go Outdated Show resolved Hide resolved
AnnotationsDatasources Annotations = "datasources"
AnnotationsWeight Annotations = "weight"
AnnotationsSpeed Annotations = "speed"
AnnotationsDurationDistance Annotations = "duration,distance"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you could add a function:

func (a Annotations) Concat(b Annotations) Annotations {
    return a + "," + b
}

and use it in your code as well:

AnnotationsDuration.Concat(AnnotationsDistance)

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