Ruby service oriented architecture - how to ensure synchronization? -


i'm newbie writing service-oriented applications, might trivial question some.

my current setup this:

1 - base rails app. contains routes , application logic.
2 - few services. have extracted these base rails app. resources db extensive or used no-sql solution.

so, have ended doing this

in rails app, have places controller responds basic crud operations on places. internally http call places service.

def show     req = typhoeus::request.new('http://127.0.0.1:7439/places/#{params[:id]}.json')     @places = req.response.body end 

the problem is, if make more 1 service call, how make sure have response before rendering views ? also, 1 service call, how rails rendering process work ? example, if service takes long time respond, page gets rendered or wait infinitely response ?

i cannot answer question typhoeus i've never used it, try answer more problem in soa , helpful.

the common thread ui should composed many services , tolerant possibility of services may down or unresponsive.

you have few options:

1) drop down , composition browser. use backbone , make ajax requests each of services. can make many of these requests asynchronously , render each part of page when return - if 1 doesn't return, don't render part - or have backbone render sort of placeholder in region.

2) if want build model object in controller (as in example), have somehow handle timeouts , again - use placeholder model whatever service being unresponsive. nice thing that, depending on service, can decide how critical have data , how time you're willing wait before consider timeout , move on.

take, example, amazon product page. it's important details product service - if don't that, it's worth throwing error browser. if "customers purchased product purchased..." service not responding, it's ok stop waiting , render page without it.

again - don't know typhoeus i'm not sure how manage using it, helps. luck!


Comments

Popular posts from this blog

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -