LA RubyConf 2009 Waves And Resource-Oriented Architecture
-
Upload
dan-yoder -
Category
Technology
-
view
708 -
download
1
Transcript of LA RubyConf 2009 Waves And Resource-Oriented Architecture
dan yoderdirector.hacking
[email protected]://twitter.com/dyoder
http://dev.zeraweb.com/
AutoCode • Functor • Filebase Waves • Pages • Hoshi • DateJS
interactiver&d
The Web Isn’t MVCSo Why Do We Use It So Often For Web Apps?
http://www.flickr.com/photos/seokchanyun/
RSS: From Blogs To PodcastsFeed provides RDF-like metadata, media-type can vary, many different clients.http://www.flickr.com/photos/abletoven/
OAuth Smart ProxiesLike firewalls for your apps - implementors don’t need to add OAuth support directly.
ConsumerProviderProxy
get request token
get permissionResource
access token
OAuthHTTP Auth
login
grant permission
access resource
Video SearchEdge caching takes the burden of caching away from overloaded servers.http://www.flickr.com/photos/33122834@N06/
ROA Solves An Old Problem.RPC? CORBA? DCOM? DSOM? RMI? SOA?
http://www.flickr.com/photos/secretlondon/
Be platform neutral.Don’t assume anything about the format of an object. Let the client specify it, instead.http://www.flickr.com/photos/dirigibleduck/
Be Wire Neutral, Too.Protocols evolve and change. Make it possible to link to resources using older protocols.http://www.flickr.com/photos/megans_photography/
Define Meta-Object Protocols“Uniform stateless interface” means rich interactions happen on the client.
Don’t Forget Performance.This means edge caching and pushing computation out to the client.http://www.flickr.com/photos/24293932@N00/
Allow Layered ArchitecturesProxies and gateways can decouple server implementations from network policies.http://www.flickr.com/photos/rengel134/
Rich DSL for HTTP requestson( :get, [ ‘location’ ], :query => { :lat => /\d{4}/, :long => /\d{4}/ }, :accept => [ :json, :xml ] )
But it’s still just Ruby ...pages $ waves console
Pages::Resources::Story.instance_methods & %w( get put post delete )
# => ["delete", "post", "put", "get"]
Resource Classes
Inheritance. I can now just inherit from a base class to provide common REST features.
Modularity. Request-handling is broken down into logically discrete chunks, just like normal classes.
Performance. I don’t have to go through each possible match - just those for the matching resource.
The One File Waves App
module HelloWorld
include Waves::Foundations::Compact module Resources class Map on( :get, [] ) { "Hello #{query.name}" } end end
end
A Resource DSL
class Blog include Waves::Resource::Server resource :list, :expires => 3.days, [ ‘blogs’ ] do get { model.find_all } end resource :element, :expires => 3.days, [ ‘blog’, :name ] do get { model.find_by_name( captured.name ) } end schema :element, [ 'schema', 'blog', '2009-03' ] do attributes :title => String, :description => String link :entries, :list => Story end representations :list do as :html, :lang => :en do | blogs | view( :blog ).list( blogs ) end endend
Waves::Vitals
Initial 0.7.0 release Feb 08Release 0.8.3 Available Soon!
Of course, we’re on git.http://github.com/waves/stable
Join Us On Google Groups.rubywaves
irc:freenode.net#waves
And, lest we forget, a Web site.http://rubywaves.com/