-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
WIP: Use Libpostal service #146
base: master
Are you sure you want to change the base?
Conversation
363c7c2
to
b86e5ae
Compare
0568fc2
to
3ed4275
Compare
3ed4275
to
9451536
Compare
0b64178
to
c815f95
Compare
c815f95
to
dd81c1b
Compare
dd81c1b
to
f828890
Compare
This has now been rewritten to use Promises, However this should be a big change as the interpolation service will take only a few MB of RAM, and is thus much easier and cheaper to deploy. |
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.
partial review: just wanted to discuss how the async/await stuff looks.
number: analyze.housenumber( number ), | ||
street: analyze.street( street ) | ||
}; | ||
analyze.street(street, function streetAnalyzeCallback(err, street, metadata) { |
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.
What's the idea behind this syntax? It seems... verbose
analyze.street(street, function streetAnalyzeCallback(err, street, metadata) {
wouldn't that be simpler as:
analyze.street(street, (err, street, metadata) => {
I see that streetAnalyzeCallback
isn't referenced anywhere else in the file so I'm guessing it's for stack traces?
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 see in another file below that you're using the syntax:
const analyze_street = util.promisify(analyze.street);
var names = await analyze_street();
I think that syntax is much cleaner, and it allows you to leave most of the code untouched and avoids the closure?
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.
This was simply because I was hoping to avoid having to use async/await
syntax at all in this PR. Despite the verboseness I'm honestly not a fan of additional language complexity. Functions are well understood by everyone :)
However, because later on we are depending on many calls to libpostal returning before proceeding, using Promisify.all
is basically the only way to get the behavior we want.
Since we're already going to be using the new syntax, I'll update this code to use it as well.
Turns out there is some more work to do:
|
f828890
to
92f66f7
Compare
e278584
to
80e6621
Compare
80e6621
to
54575f0
Compare
BREAKING CHANGE Use microservice-wrapper to avoid having to load libpostal locally. Note: this now requires a new configuration section in `pelias.json`, a top-level `services` key with the usual properties. Here's an example full `pelias.json`: ``` { "api": { "textAnalyzer": "libpostal" }, "services": { "libpostal": { "url": "http://libpostal-service-url:8080", "timeout": 4000 } } } ``` Fixes #106
Libpostal data no longer is needed
54575f0
to
72ae93f
Compare
Looking for early review, not 100% production ready yet
Use microservice-wrapper to avoid having to load libpostal locally.
Note: this now requires a new configuration section inpelias.json
, atop-level
services
key with the usual properties. Here's an examplefull
pelias.json
:Update: The code will fall back to
api.services.libpostal
ifservices.libpostal
is not defined. This helps ensure backwards compatibility.Notes
This is a breaking change, since a new configuration option is required.
The deasync module was chosen to give the libpostal service a synchronous-like interface. We should carefully evaluate whether there are any issues with this. We can avoid using it, however it would be quite a bit of work, as many sections of the code, including lots of unit tests, would have to be re-written in a callback style.See update below, this code has now been rewritten in an asynchronous style.
Fixes: #106