From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS14383 205.234.109.0/24 X-Spam-Status: No, score=1.0 required=3.0 tests=AWL,HK_RANDOM_FROM, MIME_QP_LONG_LINE,MSGID_FROM_MTA_HEADER shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Eric Wong Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: rainbows for 3rd party api Date: Fri, 6 Nov 2009 19:20:20 +0000 Message-ID: <20091106192020.GA11050@dcvr.yhbt.net> References: <2007122a0911041049u2b4376dbpd3b1f727e315ea88@mail.gmail.com> <20091104214018.GA25942@dcvr.yhbt.net> <2007122a0911050503x5740cf3ei4f1185b4cb895298@mail.gmail.com> <20091105230638.GA7131@dcvr.yhbt.net> <2007122a0911060240j105c1fcfgfebb2c5757cf7fd1@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1257535614 31258 80.91.229.12 (6 Nov 2009 19:26:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 6 Nov 2009 19:26:54 +0000 (UTC) To: Rainbows! list Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Fri Nov 06 20:26:46 2009 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Content-Disposition: inline In-Reply-To: <2007122a0911060240j105c1fcfgfebb2c5757cf7fd1-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> User-Agent: Mutt/1.5.18 (2008-05-17) X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:22 Archived-At: Received: from rubyforge.org ([205.234.109.19]) by lo.gmane.org with esmtp (Exim 4.50) id 1N6USL-0005T1-RV for gclrrg-rainbows-talk@m.gmane.org; Fri, 06 Nov 2009 20:26:46 +0100 Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 5FCDC18582C9; Fri, 6 Nov 2009 14:26:45 -0500 (EST) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by rubyforge.org (Postfix) with ESMTP id 56BB41858282 for ; Fri, 6 Nov 2009 14:20:22 -0500 (EST) Received: from localhost (dcvr.yhbt.net [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPSA id C2C201F585; Fri, 6 Nov 2009 19:20:21 +0000 (UTC) Giovanni Lion wrote: > On Fri, Nov 6, 2009 at 12:06 AM, Eric Wong wrote: > > Giovanni Lion wrote: > >> 4) I write the response to memcached > >> 5) I call the rails app who now fetches from cache the friend list > >> 6) The rails app renders the partial and everybody is happy > >> > >> Do you think this is a good flow? Should I create a specific method in= stead? > > > > Depends on the rest of your app, I guess. =A0Is your Rails app > > reentrant? =A0If so, definitely go for it. =A0If you're dealing > > with DB connections in there, compatibility will probably be > > better with the ThreadPool or ThreadSpawn models unless somebody > > writes Revactor-enabled DB libraries. > = > Well, I do have a db in there but it's just one users table, which i > really need only to pair the facebook id to the oauth tokens to make > the api calls. Unfortunately it's a 3-legged oauth so i'm kinda stuck > with having my own db. I'm testing now something like this: > = > map("/3rd_party/friends") do > use Rack::Facebook #checking the fb signature > run lambda { |env| > request =3D Rack::Request.new(env) > return Rack::Response.new(["Invalid Facebook signature"], > 400).finish unless request.POST['fb_sig'] > user =3D User.find_by_fb_id(request.POST['fb_sig_user']) #db query > ... > oauth_stuff_i_am_still_working_on > .... > } > end > = > Will rails connection pool mess things up if used in an actor? Right > now I'm really much more worried about the app being blocked in the > http call as the third party is acting wonky lately. Db load is not a > worry for now. > = > Let me know your thoughts while I get the oauth - revactor http going. I don't think there's any need to worry if your DB queries are fast and predictable in performance. Let us know how everything goes. 3rd-party API calls often pose a scalability issue that Rainbows! is designed to solve. -- = Eric Wong