OSCON 2012: ql.io and Node.js

36
node.js and ql.io OSCON July 20, 2012 1

description

OSCON 2012 (July - Portland, OR) presentation by Subbu Allamaraju and myself on ql.io and Node.js

Transcript of OSCON 2012: ql.io and Node.js

Page 1: 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

Page 2: OSCON 2012: ql.io and Node.js

2

Subbu [email protected]/s3u

Page 3: OSCON 2012: ql.io and Node.js

3

Jon [email protected]/jcleblanc

Page 4: OSCON 2012: ql.io and Node.js

4

How to consume HTTP APIs

cheaply and efficiently

Page 5: OSCON 2012: ql.io and Node.js

5

curl -X <HTTP method> <URI>

Page 6: OSCON 2012: ql.io and Node.js

Real code (randomized)

Page 7: OSCON 2012: ql.io and Node.js

7

Page 8: OSCON 2012: ql.io and Node.js

8

Page 9: OSCON 2012: ql.io and Node.js

9

Page 10: OSCON 2012: ql.io and Node.js

10

Page 11: OSCON 2012: ql.io and Node.js

11

Page 12: OSCON 2012: ql.io and Node.js

12

Page 13: OSCON 2012: ql.io and Node.js

13

Page 14: OSCON 2012: ql.io and Node.js

14

Page 15: OSCON 2012: ql.io and Node.js

15

Find things from AFor each thing, find details from BFor each thing, find more details from CMerge results

Use case:

Page 16: OSCON 2012: ql.io and Node.js

16

Find productsFind dominant categories of productsLook up category info Merge categories with products

Use case:

Page 17: OSCON 2012: ql.io and Node.js

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:

Page 18: OSCON 2012: ql.io and Node.js

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!

Page 19: OSCON 2012: ql.io and Node.js

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?

Page 20: OSCON 2012: ql.io and Node.js

20

Build Your Own Optimized APIs

Page 21: OSCON 2012: ql.io and Node.js

21

https://github.com/ql-io/

ql.ioPlatform Engineering

Page 22: OSCON 2012: ql.io and Node.js

22

A domain specific language for HTTP client programming

Page 23: OSCON 2012: ql.io and Node.js

23

cut down lines of code

reduce no of requests

save bandwidth

Page 24: OSCON 2012: ql.io and Node.js

24

Page 25: OSCON 2012: ql.io and Node.js

25

http://ql.io/console

Page 26: OSCON 2012: ql.io and Node.js

26

ServerWeb Node.js

ql.io Installation Modes

Page 27: OSCON 2012: ql.io and Node.js

27

curl http://<host>/q?s=query

Page 28: OSCON 2012: ql.io and Node.js

As a Standalone Server

Node Host

ql.io

Data (intern

al)

Data (external)

Page 29: OSCON 2012: ql.io and Node.js

# As a node.js modulenpm install ql.io-engine

Page 30: OSCON 2012: ql.io and Node.js

// 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){ … });});

Page 31: OSCON 2012: ql.io and Node.js

Language: Defining a Data Source

Include in .ql fileInclude in Request

Page 32: OSCON 2012: ql.io and Node.js

Example: Mustache Templates

Page 33: OSCON 2012: ql.io and Node.js

Example: jQuery for Cross Domain Reqs

Page 34: OSCON 2012: ql.io and Node.js

Let’s Do It!

Page 35: OSCON 2012: ql.io and Node.js

35

1. Interop via HTTP

2. SQL inspired3. Implicit

orchestration4. Failure modes5. Consumer

oriented

Page 36: OSCON 2012: ql.io and Node.js

36

code

https://github.com/ql-io/ql.iodocs/demos

http://ql.iohttps://github.com/

jcleblanc/api-masherblog

http://ql-io.github.com