Çok fazla açık kaynaklı projesi bulunmayan Ebay (https://www.ebayopensource.org/) ql.io projesi ile teknik anlamda beni etkileyen bir projeye imza atmış. ql.io nedir derseniz özetle istemci tarafından tek bir istek ile sunucu tarafında birden çok web servis isteğini birleştirilip dönebilme özelliği sunan bir yazılım. Arkaplanda nodejs (http://nodejs.org/) kullanıyor.
Daha kolay anlamak için örnek yapabiliriz. Web console (http://ql.io/console) açtıktan sonra rest servislerinizi bir veritabanı tablosu gibi tanıtıyoruz. Örnek olarak
-- A table to find products
create table eBay.FindProducts
on select get from "http://open.api.ebay.com/shopping?callname=FindProducts&appid={^apikey}&responseencoding=JSON&version=725&QueryKeywords={^QueryKeywords}&MaxEntries={max}&ProductSort=Popularity&AvailableItemsOnly=true&siteid={siteid}"
using defaults max = "5", apikey = "{config.eBay.apikey}", sideid = 0
resultset 'Product';
-- A table to get product details
create table eBay.ProductDetails
on select get from "http://open.api.ebay.com/shopping?callname=FindProducts&appid={^apikey}&responseencoding=JSON&version=725&siteid={siteid}&ProductID.type={^ProductType}&ProductID.Value={^ProductID}"
using defaults apikey = "{config.eBay.apikey}", sideid = 0
resultset 'Product';
-- A table to get product reviews
create table eBay.ProductReviews
on select get from "http://open.api.ebay.com/shopping?callname=FindReviewsAndGuides&ProductID.Value={#^ProductID}&ProductID.type={^ProductType}&appid={^apikey}&responseencoding=JSON&version=745&siteid={siteid}"
using defaults apikey = "{config.eBay.apikey}", sideid = 0;
Run ettiğimiz zaman bu servisler tablo olarak oluşuyor. (show tables diyerek görebilirsiniz). Daha sonra örnek bir istek yapıyoruz:
prodid = select ProductID[0].Value from eBay.FindProducts where
QueryKeywords = 'macbook pro';
details = select * from eBay.ProductDetails where
ProductID in ('{prodid}') and ProductType = 'Reference';
reviews = select * from eBay.ProductReviews where
ProductID in ('{prodid}') and ProductType = 'Reference';
return select d.ProductID[0].Value as id, d.Title as title,
d.ReviewCount as reviewCount, r.ReviewDetails.AverageRating as rating
from details as d, reviews as r
where d.ProductID[0].Value = r.ProductID.Value;
Çalıştırdığınız zaman arka planda servisler birbirini beklemeden çağırılıyor ve sonuç birleştirilerek size dönüyor.
Bence mutlaka incelenmesi gereken çok başarılı bir proje.
Detaylı bilgi:
http://ql.io/
http://www.ebaytechblog.com/2011/11/30/announcing-ql-io/