-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
Updated code with proposed changes |
4e40b18
to
955d9aa
Compare
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.
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" |
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.
FallbackCoordinateSnapped FallbackCoordinate
as well
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.
Yes, you are right.
I used this like iota :)
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.
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" |
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.
Why do you need that?
Maybe add a function to combine multiple annotations in a request?
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.
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.
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.
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)
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.
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.
Yes, this cannot be backward compatible, unless I copy params from the embedded struct GeneralOptions to 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. |
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" |
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.
It doesn't work like iota. You must declare the type explicitly.
https://play.golang.org/p/iVeaitEtA2k
Sure, I know that. |
AnnotationsDatasources Annotations = "datasources" | ||
AnnotationsWeight Annotations = "weight" | ||
AnnotationsSpeed Annotations = "speed" | ||
AnnotationsDurationDistance Annotations = "duration,distance" |
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.
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)
No description provided.