Giter Site home page Giter Site logo

puneetjaiswal / api-gateway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lyft/presto-gateway

1.0 1.0 0.0 1.96 MB

A load balancer / proxy / gateway for web based services

License: Apache License 2.0

Java 9.10% FreeMarker 0.43% JavaScript 88.87% TSQL 0.06% CSS 1.51% Dockerfile 0.02% Shell 0.01%

api-gateway's Introduction

api-gateway

A load balancer / proxy / gateway for web APIs and Services.

How to setup a dev environment

Step 1: setup mysql. Install docker and run the below command when setting up first time:

docker run -d -p 3306:3306  --name mysqldb -e MYSQL_ROOT_PASSWORD=root123 -e MYSQL_DATABASE=prestogateway -d mysql:5.7

Next time onwards, run the following commands to start mysqldb

docker start mysqldb

Now open mysql console and install the presto-gateway tables:

mysql -uroot -proot123 -h127.0.0.1 -Dprestogateway

Once logged in to mysql console, please run gateway-ha-persistence.sql to populate the tables.

Step 2: Edit the configuration gateway-ha-config.yml

Step 3: Add below program argument to class HaGatewayLauncher and debug in IDE

server /path/to/gateway-ha/src/test/resources/config-template.yml

Build and run

run mvn clean install to build presto-gateway

Edit the config file and update the mysql db information.

cd gateway-ha/target/
java -jar gateway-ha-{{VERSION}}-jar-with-dependencies.jar server ../gateway-ha-config.yml

Now you can access load balanced presto at localhost:8080 port. We will refer to this as prestogateway.lyft.com

Gateway API

Add or update a backend

curl -X POST http://localhost:8080/entity?entityType=GATEWAY_BACKEND \
 -d '{  "name": "presto1", \ 
        "proxyTo": "http://presto1.lyft.com",\
        "active": true, \
        "routingGroup": "adhoc" \
    }'

curl -X POST http://localhost:8080/entity?entityType=GATEWAY_BACKEND \
 -d '{  "name": "presto2", \ 
        "proxyTo": "http://presto2.lyft.com",\
        "active": true, \
        "routingGroup": "adhoc" \
    }'

Get all backends behind the gateway

curl -X GET http://localhost:8080/entity/GATEWAY_BACKEND
[
    {
        "active": true,
        "name": "presto1",
        "proxyTo": "http://presto1.lyft.com",
        "routingGroup": "adhoc"
    },
    {
        "active": true,
        "name": "presto2",
        "proxyTo": "http://presto2.lyft.com",
        "routingGroup": "adhoc"
    }
]

Deactivate a backend

curl -X POST http://localhost:8080/gateway/backend/deactivate/presto2

Get all active backend behind the Gateway

curl -X GET http://localhost:8080/gateway/backend/active | python -m json.tool

    [{
        "active": true,
        "name": "presto1",
        "proxyTo": "http://presto1.lyft.com",
        "routingGroup": "adhoc"
    }]

Activate a backend

curl -X POST http://localhost:8080/gateway/backend/activate/presto2

Query History UI - check query plans etc.

PrestoGateway records history of recent queries and displays links to check query details page in respective presto cluster.
prestogateway.lyft.com

Gateway Admin UI - add and modify backend information

The Gateway admin page is used to configure the gateway to multiple backends. Existing backend information can also be modified using the same. prestogateway.lyft.com/entity

Contributing

Want to help build Presto Gateway? Check out our contributing documentation

References โœจ

Scaling Presto Infra with gateway at Lyft

Presto-gateway at Pinterest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.