Slide 1

Slide 1 text

The Worker Pattern Thursday, March 7, 13

Slide 2

Slide 2 text

Confession Thursday, March 7, 13

Slide 3

Slide 3 text

BACKGROUND ALL THE THINGS! Thursday, March 7, 13

Slide 4

Slide 4 text

Request work •••••••••••• Thursday, March 7, 13

Slide 5

Slide 5 text

Example Acme API Feed * item 1 * item 2 * item 3 ... Thursday, March 7, 13

Slide 6

Slide 6 text

class AcmeIntegrationController def index api = AcmeAPI.new(user_token) @feed = api.get_user_feed end end Thursday, March 7, 13

Slide 7

Slide 7 text

I heard you requests... so i put a request inside your request Thursday, March 7, 13

Slide 8

Slide 8 text

class AcmeIntegrationController def index if fragment.exists? @feed = fragment.data else fragment.fetch_in_background @feed = nil end ... Thursday, March 7, 13

Slide 9

Slide 9 text

# app/views/acme_integration/index.html <% if @feed.present? -%> <%= render @feed %> <% else -%> <%= feed_fragment_helper %> <% end -%> Thursday, March 7, 13

Slide 10

Slide 10 text

Example Acme API Feed loading... Thursday, March 7, 13

Slide 11

Slide 11 text

http status 204 http://httpstatus.es/204 Thursday, March 7, 13

Slide 12

Slide 12 text

Example Acme API Feed * item 1 * item 2 * item 3 ... Thursday, March 7, 13

Slide 13

Slide 13 text

The Worker Pattern resources Ryan Smith: * slides: rails conf 2010 * Video: talk at waza 2011 Rack Worker on Github speakerdeck.com/leejones ••• Thursday, March 7, 13