Home

Awesome

[_] Gateleen

Build Status codecov GitHub contributors

GitHub release Maven Central

Gateleen is a RESTFul middleware toolkit for building API gateways.

Getting Started

Install

Build

You need Java 8 and Maven

cd gateleen
mvn install

We're using a (private) mirror where we download npm/node from. In case you've no access to that mirror, you can use maven profile publicRepos (Eg: mvn install -PpublicRepos).

Play

A Redis is needed for this

redis-server

The gateleen-playground module provides a server example.

java -jar gateleen-playground/target/playground.jar

It starts on http://localhost:7012/playground

The storage is currently empty, that's why you get 404 Not Found

Upload some demo stuff using

mvn deploy -PuploadStaticFiles

The playground module provides a convenient web client for manipulating resources and a basic configuration.

Create your first resource with

curl -X PUT -d '{ "foo": "bar" }' http://localhost:7012/playground/hello/world

or any other REST Client

Now you can see the resource appear in http://localhost:7012/playground

Run integration tests

Once the playground is up the UI based integration tests can be executed using

mvn install -PuiIntegrationTests -Dsel_chrome_driver=/usr/local/chromedriver

there are also integration tests that are not based on the playground UI.

Note: Stop the playground prior to running these test:

mvn install -PnonUiIntegrationTests 

Modules

ModuleDescription
coreHTTP infrastructure and hierarchical resource storage that can be used as cache, intermediate storage for backend-pushed data, user and apps data
cacheCache JSON responses locally to reduce load on backends and increase performance.
delegateWith the delegate feature a client is able to delegate requests to perform prespecified tasks.
deltaTraffic optimization allowing clients to fetch only data that actually changed from the last time they fetched it
expansionTraffic optimization allowing clients to fetch a sub-tree of data in one request instead of many requests
hookServer push and callback support allowing backends to push data to clients and be notified when data is pushed by clients
integrationtestTest infrastructure
loggingLogs request with configurable filtering for later data analysis
monitoringMonitor useful information like number of requests, queue sizes, etc.
packingTraffic optimization gathering multiple requests in one
performancetestExecute load tests using Gatling.io against a running playground instance
playerTest tool to replay traffic recorded with gateleen-logging for automated tests and troubleshooting
playgroundServer example
qosTraffic priorization by rejecting requests to low-priority routes to keep more important features working when backends go down and load increases due to timeouts and retries
queueRequest queuing to be robust to slow and available backends keeping the client connections short-lived
routingConfigurable URL patterns and method based routing to backends and resource storage
runconfigTest infrastructure
schedulerPerforms planned operations like data cleaning
securityFine grained authorization for URL patterns and methods against principal headers
testIntegration tests
userManages user profile merges user preferences and identity information
validationValidates data according to JSON schemas
kafkaForward requests to Kafka topics

Headers

This is a list of the custom headers used by Gateleen.

HeaderDescriptionLink to documentation
x-rp-unique-idunique id
x-request-idid of the request (unique?)
x-self-requestindicates if the request is triggered by a communication server and the target is the communication server itself
x-rp-grpgroup headergateleen-user
x-rolesrole header
x-deltaused by the delta parameter to mark a delta requestgateleen-delta
x-delta-backendused by the delta parameter as a marker header to know that we should let the request continue to the routergateleen-delta
x-expire-Afterindicates how long (in seconds) a request is 'valid' before it expires
x-hookedused by the HookHandler to indicate the original hook request as hookedgateleen-hook
x-pack-sizeindicates if a request is packedgateleen-packing
x-client-timestamptimestamp of the client while sending the request
x-server-timestamptimestamp of the server while sending the request
x-queueindicates a queued requestgateleen-queue
x-duplicate-checkindicates if a request is a duplicate or not
x-on-behalf-ofindicates the user the request originally was made from. This header is used when the request of a user is sent by another user because it couldn't be sent at that time (offline)
x-user-<pattern>used for the user profile
x-rp-deviceidused to check if device is authorized
x-rp-usrused to check if user is authorizedgateleen-user
x-rp-langused to specify the language of the user profilegateleen-user
x-validindicates if a request is to be validated or notgateleen-validation
x-sync
x-log
x-servicecontains the name of the service, which created the request
x-queue-expire-afterindicates how long (in seconds) a request is 'valid' in the queue before it expires

Performance Tuning

Dependencies