hotosm / galaxy-api

Backend to fetch data from Underpass
https://galaxy-api.hotosm.org/latest/redoc
GNU Affero General Public License v3.0
14 stars 5 forks source link

[Feature] Task Queue System & Rate Limit on API #335

Open kshitijrajsharma opened 2 years ago

kshitijrajsharma commented 2 years ago

This will also solve failing Github action issue of https://github.com/hotosm/galaxy-api/pull/326

Features :

Implementation details :

Test This PR :

Simply checkout this feature/celery branch and start from docs/GETTING_SARTED_WITH_DOCKER here

This PR involves some major changes on documentation so I recommend going through docs will be very useful to test it

Once the API is up and running , post Sample request provided on rawdata endpoint It should give you your unique task id.

Follow the steps to track status

Meanwhile navigate to flower To see what worker is doing and job status / info

You can hit the /current-snapshot/ multiple times when you reach more than 5 request per min ,API will block the request and You should see too many requests error

NicolasGrosjean commented 2 years ago

I fail to run the project with the docker-compose, it seems it doesn't find my database whereas I found it in local

image

In fact, if I connect to the app docker, install postgresql-client, I get the error.

image

How should I configure app to have access to my database ?

For information, I run postgis with docker-compose which works well in develop branch. I added the postgis service in the depends_on section of app but it changed nothing.

  postgis:
    image: postgis/postgis:14-3.3
    container_name: "postgis"
    ports:
      - "5439:5432"
    environment:
      - POSTGRES_DB=test
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=admin
    restart: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"
kshitijrajsharma commented 2 years ago

I fail to run the project with the docker-compose, it seems it doesn't find my database whereas I found it in local

image

In fact, if I connect to the app docker, install postgresql-client, I get the error.

image

How should I configure app to have access to my database ?

For information, I run postgis with docker-compose which works well in develop branch. I added the postgis service in the depends_on section of app but it changed nothing.

  postgis:
    image: postgis/postgis:14-3.3
    container_name: "postgis"
    ports:
      - "5439:5432"
    environment:
      - POSTGRES_DB=test
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=admin
    restart: on-failure
    logging:
      driver: "json-file"
      options:
        max-size: "200k"
        max-file: "10"

Oh ! I think i know the problem , For me it works because I use ssh tunnel , But may not work for the postgres lying on local machine. Since docker container is requesting connection outside the network when we specify localhost : container reference to it's own locahost instead , Try replacing it with your device network ip address it should be able to connect ! ( I use ifconfig to know ip ) . Let me know if it works ! I will include this in docs as well

kshitijrajsharma commented 2 years ago

Update : Replacing my network ip with localhost worked for me with my local Postgres ! I found this article as well