# Strategy for integrating a custom layer of web services?

**URL:** <https://www.ruby-forum.com/t/strategy-for-integrating-a-custom-layer-of-web-services/192100>\
**Category:** Rails\
**Created:** [July 23, 2010, 6:35pm UTC](https://www.ruby-forum.com/t/strategy-for-integrating-a-custom-layer-of-web-services/192100 "2010-07-23T18:35:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@luc](https://www.ruby-forum.com/u/luc)\
**Post date:** [July 23, 2010, 6:35pm UTC](https://www.ruby-forum.com/t/strategy-for-integrating-a-custom-layer-of-web-services/192100/1 "2010-07-23T18:35:26Z")

</div>

Hi all,

I have built a rails application with a custom layer of web and media  
services with different features.

First, there is a data retrieval service which works in the following  
steps:

- On rails startup, one autonomous thread is instantiated for each  
service (we work with JRuby for performance reasons).
- Data and atimes are stored in rails synchronized memory store, and  
threads activate themselves or adjust their delay (from 10 to 1  
second) when clients connect to the site and start sending Ajax  
requests (every second).

We do this because we want to save on bandwith (it is still huge files  
even though we moved from xml to json) and limit the computing  
capacity needed for these services (on the data sources).

Second, the system talks to a REST API on these data sources but we  
sometimes have to keep some kind of stateful representation of the  
data sources because depending on the context some calls should not be  
forwarded (FSM-like behavior). I will also have to implement an  
exclusive lock system because in some cases it is required that only  
one client at a time is able to talk to this API.

Third, we need to be able to control an MJPG streaming server (written  
in Ruby as well) that serves video streams to custom Flash clients.

So this services layer is currently implemented as a small framework  
in its own right and everything is initialized when rails starts. The  
reason for that is that I had to develop everything under severe time  
constraints.

Now that the doability of the project has been validated and we will  
very likely stick with rails, I am looking for ways to better  
integrate all these components with rails but I do not really know  
where to start. Should I pluginify as much as possible? Should I  
create some kind of LiveDataEntity - View - Controller apps? Do my  
requirements necessitate to extend rails itself or is there already  
some clean way to satisfy them?

Any thoughts welcome.

Thanks.

---

<div class="post-metadata">

**Author:** ![luc](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/9dc877/32.png) [@luc](https://www.ruby-forum.com/u/luc)\
**Post date:** [July 24, 2010, 9:22pm UTC](https://www.ruby-forum.com/t/strategy-for-integrating-a-custom-layer-of-web-services/192100/2 "2010-07-24T21:22:46Z")

</div>

Difficult to tell what your requirements are except for “integrate all  
these components with rails”.
