OSCON 2012: ql.io and Node.js
-
Upload
jonathan-leblanc -
Category
Technology
-
view
105 -
download
0
description
Transcript of OSCON 2012: ql.io and Node.js
1
node.js and ql.io
Build Your Own HTTP APIs for Agility and Scale
OSCON July 20, 2012
2
Subbu [email protected]/s3u
3
Jon [email protected]/jcleblanc
4
How to consume HTTP APIs
cheaply and efficiently
5
curl -X <HTTP method> <URI>
Real code (randomized)
7
8
9
10
11
12
13
14
15
Find things from AFor each thing, find details from BFor each thing, find more details from CMerge results
Use case:
16
Find productsFind dominant categories of productsLook up category info Merge categories with products
Use case:
17
Get stuff from AIf A is down, try from BAnnotate stuff with other stuff from CIgnore some things from the stuffJoin all
Use case:
18
Prod
ucer
sClie
nt
[Really important client]
Why don't you give me an API optimized for my use cases?
Serv
er
[Really important producer]
Thanks. Get a number and stand in the line!
19
Prod
ucer
sClie
nt
Serv
er
[Really important producer]
Thanks. Get a number and stand in the line!
Who gets to decide the right thing?
[Really important client]
Why don't you give me an API optimized for my use cases?
20
Build Your Own Optimized APIs
21
https://github.com/ql-io/
ql.ioPlatform Engineering
22
A domain specific language for HTTP client programming
23
cut down lines of code
reduce no of requests
save bandwidth
24
25
http://ql.io/console
26
ServerWeb Node.js
ql.io Installation Modes
27
curl http://<host>/q?s=query
As a Standalone Server
Node Host
ql.io
Data (intern
al)
Data (external)
# As a node.js modulenpm install ql.io-engine
// Use ql.io from node.jsvar Engine = require('ql.io-engine');var engine = new Engine({
//OPTIONS});
var script = '…';engine.execute(script, function(emitter){ emitter.on("end", function(err, res){ … });});
Language: Defining a Data Source
Include in .ql fileInclude in Request
Example: Mustache Templates
Example: jQuery for Cross Domain Reqs
Let’s Do It!
35
1. Interop via HTTP
2. SQL inspired3. Implicit
orchestration4. Failure modes5. Consumer
oriented
36
code
https://github.com/ql-io/ql.iodocs/demos
http://ql.iohttps://github.com/
jcleblanc/api-masherblog
http://ql-io.github.com