PaddeK / node-maxmind-db

This is the pure Node API for reading MaxMind DB files. MaxMind DB is a binary file format that stores data indexed by IP address subnets (IPv4 or IPv6).
GNU Lesser General Public License v2.1
88 stars 25 forks source link

Asynchronous API? #8

Closed rickhuizinga closed 10 years ago

rickhuizinga commented 10 years ago

First, this makes it fantastically easy to use the MaxMind DB in Node.js.

Is there, or will there be, an asynchronous version of the getGeoData function?

I'm concerned that the synchronous version is going to block my server to only being able to handle one request at a time while execution is blocked on file I/O when calling the getGeoData function.

the-eater commented 10 years ago

Well as you can see in the code is it all sync and logic, so how would you want to implement this?

ryanhuff commented 10 years ago

As:

// require the db reader
var mmdbreader = require('maxmind-db-reader');
//  create new reader from a countries file
var countries = new mmdbreader('./countries.mmdb');
// get geo data and console.log it 
countries.getGeoData('8.8.8.8', function(data, err) {
   console.log("geo data", data);
});
the-eater commented 10 years ago

Well, that is obvious but I meant more like how to implement that in the code, but I think I know a way. also since @PaddeK doesnt really react I recommend to use my fork since that has the most bugs fixed. Will let you guys know when I get async working

the-eater commented 10 years ago

@rickhuizinga in my repo is now an async version, beware tho, I broke the API

rickhuizinga commented 10 years ago

@EaterOfCode Thanks! I'll take a look.

ryanhuff commented 10 years ago

This is great. Thanks!

the-eater commented 10 years ago

Thanks to the merge this issue is fixed