Webhooks - glue for the web

60
Webhooks glue for the Web 1 20 юни 2009, събота

description

Presentation for the 34th Ruby-Kansai meeting. Credits: some of the images inside are from the Jeff Lindsay's presentations "Web Hooks and the Programmable World of Tomorrow" and "Using Web Hooks" (see the presenter notes below the slides)

Transcript of Webhooks - glue for the web

Page 1: Webhooks - glue for the web

Webhooksglue for the Web

120 юни 2009, събота

Page 2: Webhooks - glue for the web

Who am I ?

• Name: Stoyan Zhekov

• Private: married, 3 kids (boys)

• Work: Software Engineer

• Contact: xmpp: //[email protected]

220 юни 2009, събота

Page 3: Webhooks - glue for the web

320 юни 2009, събота

Page 4: Webhooks - glue for the web

Today

• What is this talk about?

• What are webhooks?

• What can they do for me?

• Pros and cons

• Real life usage

420 юни 2009, събота

Maybe you already forget the presentation title, so one more time...

Page 5: Webhooks - glue for the web

What is this talk about?

520 юни 2009, събота

Page 6: Webhooks - glue for the web

Webhooksglue for the Web

620 юни 2009, събота

Page 7: Webhooks - glue for the web

Hooks?720 юни 2009, събота

Page 8: Webhooks - glue for the web

Glue?820 юни 2009, събота

Page 9: Webhooks - glue for the web

Web 3.0920 юни 2009, събота

Don’t worry. We will talk about web :)

Page 10: Webhooks - glue for the web

Web x.0?

• Web 1.0 - static

• Web 2.0 - dynamic? social?

• Web 3.0 - real time?

1020 юни 2009, събота

Google Wave, iPhone push notifications

Page 11: Webhooks - glue for the web

Web 3.0

• Real Time

• Does it scale?

• PubSub

1120 юни 2009, събота

Page 12: Webhooks - glue for the web

Real Time1220 юни 2009, събота

Page 13: Webhooks - glue for the web

Real Time Web

• RSS is not enough (SUP)

• XMPP

• Webhooks

1320 юни 2009, събота

I spoke in Kobe about SUP and XMPP (see my other presentations - http://www.slideshare.net/zhesto/microblogging-via-xmpp

Page 14: Webhooks - glue for the web

No Polling!1420 юни 2009, събота

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 15: Webhooks - glue for the web

Real Time1520 юни 2009, събота

Page 16: Webhooks - glue for the web

Does it scale?

1620 юни 2009, събота

Recently working a lot with EC2 - pay per use, scale easy - instant start/stop of instances

Page 17: Webhooks - glue for the web

Clouds...

1720 юни 2009, събота

Page 18: Webhooks - glue for the web

Clouds?1820 юни 2009, събота

Page 19: Webhooks - glue for the web

Computer cloud!1920 юни 2009, събота

Page 20: Webhooks - glue for the web

Communications2020 юни 2009, събота

Page 21: Webhooks - glue for the web

Communications

• Messaging (AMQP): RabbitMQ

• XMPP, Ejabberd, Prosody

• Webhooks

2120 юни 2009, събота

Webooks can help you with the infrastructure. Some service is too heavy? - move it to another machine and connect them with webhook. Think about webhooks even when on a single machine (call by URL, not by function name)

Page 22: Webhooks - glue for the web

PubSub

2220 юни 2009, събота

Page 23: Webhooks - glue for the web

Publishers2320 юни 2009, събота

Page 24: Webhooks - glue for the web

Subscribers2420 юни 2009, събота

Page 25: Webhooks - glue for the web

Publishers and Subscribers

2520 юни 2009, събота

Page 26: Webhooks - glue for the web

Watercoolr

•PubSub

•Webhooks

•Ruby

http://github.com/zh/watercoolr/http://github.com/jcapote/watercoolr/

2620 юни 2009, събота

Page 27: Webhooks - glue for the web

PubSubHubBubhttp://code.google.com/p/pubsubhubbub/

2720 юни 2009, събота

Page 28: Webhooks - glue for the web

What are webhooks?2820 юни 2009, събота

Image from the presentation “Using Web Hooks”I keep repeating webhooks, webhooks,... So what are they?

Page 29: Webhooks - glue for the web

Captain Hook2920 юни 2009, събота

Page 30: Webhooks - glue for the web

SVN Hooks3020 юни 2009, събота

Image from the presentation “Using Web Hooks”

Page 31: Webhooks - glue for the web

Hooks

• Subversion pre-commit, post-commit

• Git, Mercurial - they have hooks too

• Rails: :before_save, :after_delete

3120 юни 2009, събота

Page 32: Webhooks - glue for the web

Unix Philosophy

• do ONE THING and do it well

• programs WORK TOGETHER

• UNIVERSAL INTERFACE (text)

3220 юни 2009, събота

Insert here more about the webhooks - POST, etc.example cat | grep | mail -> make this with web too (demo)

Page 33: Webhooks - glue for the web

UNIX pipes3320 юни 2009, събота

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 34: Webhooks - glue for the web

The Web3420 юни 2009, събота

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 35: Webhooks - glue for the web

Web 3D3520 юни 2009, събота

There are services creating the web pages (feeds). Now nodes communicate via RSS - indirect.Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 36: Webhooks - glue for the web

WebApp pipes?3620 юни 2009, събота

Can we make a simple applications and connect them like a pipe?Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 37: Webhooks - glue for the web

3720 юни 2009, събота

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 38: Webhooks - glue for the web

POST /service data={ 'message':'hey guys!' }

3820 юни 2009, събота

Page 39: Webhooks - glue for the web

What are WEBhooks?

webhooks are user defined callback URLs, that point to a web script to run on a

certain event

3920 юни 2009, събота

By letting the user specify a URL for various events, the application will POST data to those URLs when the events occur. Key poins: USER DEFINED, URLs (remote services), RUN ON CERTAIN EVENT (push, no cronjobs etc.)

Page 40: Webhooks - glue for the web

User defined4020 юни 2009, събота

Page 41: Webhooks - glue for the web

URLs = remote4120 юни 2009, събота

Page 42: Webhooks - glue for the web

register URL4220 юни 2009, събота

Image from the presentation “Using Web Hooks”

Page 43: Webhooks - glue for the web

get notification4320 юни 2009, събота

Image from the presentation “Using Web Hooks”

Page 44: Webhooks - glue for the web

Why?

4420 юни 2009, събота

Page 45: Webhooks - glue for the web

Service Integration4520 юни 2009, събота

Page 46: Webhooks - glue for the web

Flexibility4620 юни 2009, събота

Page 47: Webhooks - glue for the web

Customization4720 юни 2009, събота

Image from the presentation ”Web Hooks and the Programmable World of Tomorrow”

Page 48: Webhooks - glue for the web

Webhooks movement

• Jeff Lindsay

• http://blogrium.com/?p=70

• http://webhooks.pbworks.com/

• http://blog.webhooks.org/

4820 юни 2009, събота

Page 49: Webhooks - glue for the web

Webhooks

• Amazon have Merchant Callback API

• PayPal (Instant Payment Notification)

• GitHub and Google Code

4920 юни 2009, събота

Page 50: Webhooks - glue for the web

Good and bad5020 юни 2009, събота

Page 51: Webhooks - glue for the web

Good

• Well known protocol - HTTP

• code libraries (software)

• infrastructure (hardware)

• Easy for vendors (services)

• Easy for users (consumers)

5120 юни 2009, събота

Page 52: Webhooks - glue for the web

5220 юни 2009, събота

Page 53: Webhooks - glue for the web

require ‘net/http’require ‘json’

class Userdef commit(message)

Net::HTTP.post_form( User.hook_url,{ :data => message.to_json })

endend

5320 юни 2009, събота

For service providers (publishers)

Page 54: Webhooks - glue for the web

require ‘net/smtp’require ‘json’require ‘sinatra’

post ‘/hook’ dodata = JSON.parse(params[:data])# do something with the dataNet::SMTP.start(‘localhost’) do |smtp|

smtp.send_message data[‘message’], from, to end

end

5420 юни 2009, събота

For service consumers (subscribers)

Page 55: Webhooks - glue for the web

Bad

• No standard

• Google Code: XML

• GitHub: JSON

• ping.fm - POST parameters

• Security (authentication)

5520 юни 2009, събота

Page 56: Webhooks - glue for the web

Real Life Usage

5620 юни 2009, събота

Page 57: Webhooks - glue for the web

Where to create hooks?

• http://heroku.com/ - Ruby

• GAE - Python, Java, JRuby

• http://scriptlets.org/ - Python, JS

• PHP - almost everywhere

5720 юни 2009, събота

Page 58: Webhooks - glue for the web

Ready Tools

• GitHub - RunCodeRun

• http://ping.fm/ - IM, email, Skype

• http://postbin.org/ - debug

• SwitchHub, TarPipe

• http://superfeedr.com/ - RSS

• http://bot.im/ - IMified XMPP bot

5820 юни 2009, събота

Page 59: Webhooks - glue for the web

Demoping.fm + postbin

ping.fm + switchub (+postbin)

5920 юни 2009, събота

create new hook on postbin, login to post.fm/custom/ and put there the url. test: web, email, im?

Page 60: Webhooks - glue for the web

Questions?

6020 юни 2009, събота