Skip to content

Data Sources

Mohan Kumar Pandian edited this page Jul 8, 2016 · 3 revisions

What is a Data Source?

Data Source is a re-usable component that holds a business logic (Ex: computing final price of a product after getting price, offers, delivery cost etc from different services in an e-commerce application). A Data Source may call one or more other Data Sources and one or more service clients and should return a Data Type.

What is a Data Type?

Data Type is a business entity (Ex: Product, User etc in an e-commerce application). Data Type may contain one or more other Data Types. Data Types are constructed by Data Source out of Service Responses or other Data Types after applying the required business logic. It is strictly defined based on business/product asks and not based on upstream services contracts.

Why should I have a Data Type?

We don't encourage or allow Service Responses to act as Data Types for various reasons including service responses might undergo rapid changes which shouldn't affect the contract of your API users, data types may be formed from multiple service responses etc.

How is a Data Type written?

As of now, Data Type is written as a simple Java class (POJO).

Why is a Data Source callable?

We execute business logic calls in different threads (non request threads) to provide isolation and timeout mechanisms. So for an API request, multiple data sources might get executed (based on call graph defined in API definition files). Given that APIs have timeout and data sources can get executed in parallel, its imperative to execute them in different threads. The framework passes the required context from web server threads to data source threads (including hystrix request context, zipkin request context etc).