Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
High Performance API Mashups with Node.js and ql.io
1. High Performance Mashups
Using ql.io and Node.js
Jonathan LeBlanc
Developer Evangelist (PayPal)
Twitter: @jcleblanc | @PayPalDev
Github: github.com/jcleblanc
12. Language: Including Script Routes
user = "jcleblanc";
slides = select * from slideshare where user="{user}";
twitter = select * from github.users where user="{user}";
return {
"slides": "{slides}",
"twitter": "{twitter}"
}
via route '/social' using method post;
21. Node.js: Including the Engine
var Engine = require('ql.io-engine');
var engine = new Engine({
…
});
22. Node.js: Invoking the Engine
var script = "select * from …";
engine.execute(script, function(emitter){
emitter.on("end", function(err, res){
console.log(res['body'][0]);
});
});
23. Tools: External API Tables
Tables Source:
https://github.com/jcleblanc/ql.io-tables
https://github.com/ql-io/ql.io-
site/tree/master/tables
24. Thank You! Any Questions?
http://www.slideshare.net/jcleblanc
Jonathan LeBlanc
Developer Evangelist (PayPal)
Twitter: @jcleblanc | @PayPalDev
Github: github.com/jcleblanc
Hinweis der Redaktion
Mashing up multiple data sourcesPerformance issues
Language based on a SQL-like syntax which exports all data to JSON
A create table call (to define a data source) may be included in the HTTP request to the ql.io web source or defined in a .ql file, which is added into the /tables directory of your application.
create table slideshare on select get from "http://www.slideshare.net/rss/user/{user}" resultset "rss.channel";create table github on select get from "https://api.github.com/users/{user}";user = "jcleblanc";slides = select * from slideshare where user="{user}";person = select * from github where user="{user}";return { "slides": "{slides}", "person": "{person}"}
Route files are also stored with the .ql extension but are placed under the routes directory
First we need some mustache power
Route files are also stored with the .ql extension but are placed under the routes directory
-- http://api.hunch.com/api/v1/get-recommendations/?user_id=tw_jcleblanc&topic_id=cat_electronics&limit=5create table hunch on select get from "http://api.hunch.com/api/v1/get-recommendations/?user_id={uid}&topic_ids={tid}&limit={limit}" using defaults limit="20" resultset "recommendations";--select title from hunch where uid="tw_jcleblanc" and tid="cat_electronics";select * from finditems where keywords in (select title from hunch where uid="tw_jcleblanc" and tid="cat_electronics");