Public Repository

Last pushed: 15 days ago
Short Description
Short description is empty for this repo.
Full Description

node-service-geoip



project status

Features

  • Microservice using node.js and an AMQP Broker
  • Used in production
  • Docker/ Docker Cloud ready

service install

npm install service-geoip
npm updatedb used to build the geo DB. This is not needed when module is used as a client.

docker build

docker build -t dialonce/service-geoip:latest .

configuration (env vars)

configuration can be done using env vars

#default
AMQP_URL=amqp://localhost

#default
AMQP_QUEUE=geo:ip

usage

start the service

setup env vars and start the container or run npm start

npm start
docker run dialonce/service-geoip:latest -e AMQP_URL=amqp://localhost

consume the service

npm i bunnymq --save

Then in your code:

var bunny = require('bunnymq')({ host: 'amqp://localhost' }).producer;
bunny.produce('geo:ip', '95.130.11.91', { rpc: true })
.then(function(loc){
  //use loc object here
});

consuming from a compatible amqp broker

just send the IP as the message content on the queue you have defined (see #configuration) with contentType set to application/json

Docker Cloud

Here is a sample stackfile to deploy your microservice

rabbitmq-master:
  image: 'tutum/rabbitmq:latest'
  environment:
    - RABBITMQ_PASS=PASSWORD
service-geoip:
  image: 'dialonce/service-geoip:latest'
  environment:
    - 'AMQP_URL=amqp://admin:PASSWORD@rabbitmq-master'
  links:
    - rabbitmq-master
Docker Pull Command
Owner
dialonce