Merge remote-tracking branch 'origin/development' into obs-getavailablegeometries-tags

This commit is contained in:
Rafa de la Torre
2017-05-04 14:48:02 +02:00
2 changed files with 66 additions and 30 deletions

View File

@@ -23,26 +23,12 @@ Steps to deploy a new Data Services API version :
### Local install instructions ### Local install instructions
- install data services geocoder extension
```
git clone https://github.com/CartoDB/data-services.git
cd data-services/geocoder/extension
sudo make install
```
- install observatory extension
```
git clone https://github.com/CartoDB/observatory-extension.git
cd observatory
sudo make install
```
- install server and client extensions - install server and client extensions
``` ```
# in dataservices-api repo root path: # in your workspace root path
git clone https://github.com/CartoDB/dataservices-api.git
cd dataservices-api
cd client && sudo make install cd client && sudo make install
cd - cd -
cd server/extension && sudo make install cd server/extension && sudo make install
@@ -55,16 +41,64 @@ Steps to deploy a new Data Services API version :
cd server/lib/python/cartodb_services && pip install -r requirements.txt && sudo pip install . --upgrade cd server/lib/python/cartodb_services && pip install -r requirements.txt && sudo pip install . --upgrade
``` ```
- install extensions in user database - Create a database to hold all the server part and a user for it
```sql
CREATE DATABASE dataservices_db ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';
CREATE USER dataservices_user;
```
- Install needed extensions in `dataservices_db` database
``` ```
create extension cdb_geocoder; psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS plproxy; COMMIT" -e
create extension plproxy; psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS cdb_dataservices_server; COMMIT" -e
create extension observatory;
create extension cdb_dataservices_server;
create extension cdb_dataservices_client;
``` ```
- [optional] install internal geocoder
- Make the extension available in postgres
```
git clone https://github.com/CartoDB/data-services.git
cd data-services/geocoder/extension
sudo make install
```
- Make sure you have `wget` installed because is needed for the next step.
- Go to `geocoder` folder and execute the `geocoder_dowload_dumps` script to download the internal geocoder data.
- Once the data is downloaded, execute this command:
```bash
geocoder_restore_dump postgres dataservices_db {DOWNLOADED_DUMPS_FOLDER}/*.sql
```
- Now we have to make available the extension to be installed by postgres. Follow [this](https://github.com/CartoDB/data-services/tree/master/geocoder/extension) instructions.
- Now install the extension with:
```
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS cdb_geocoder; COMMIT" -e
```
- [optional] install data observatory extension
- Make the extension available in postgresql to be installed
```
git clone https://github.com/CartoDB/observatory-extension.git
cd observatory
sudo make install
```
- This extension needs data, dumps are not available so we're going to use the test fixtures to make it work. Execute:
```
psql -U postgres -d dataservices_db -f src/pg/test/fixtures/load_fixtures.sql
```
- Give permission to execute and select to the `dataservices_user` user:
```
psql -U postgres -d dataservices_db -c "BEGIN;CREATE EXTENSION IF NOT EXISTS observatoru; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT SELECT ON ALL TABLES IN SCHEMA cdb_observatory TO dataservices_user; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA cdb_observatory TO dataservices_user; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT SELECT ON ALL TABLES IN SCHEMA observatory TO dataservices_user; COMMIT" -e
psql -U postgres -d dataservices_db -c "BEGIN;GRANT EXECUTE ON ALL FUNCTIONS IN SCHEMA observatory TO dataservices_user; COMMIT" -e
```
### Server configuration ### Server configuration
Configuration for the different services must be stored in the server database using `CDB_Conf_SetConf()`. Configuration for the different services must be stored in the server database using `CDB_Conf_SetConf()`.

View File

@@ -83,7 +83,7 @@ The result is a JSON object with the configuration (`period` and `limit` attribu
#### Example: #### Example:
``` ```
SELECT cdb_dataservices_client.cdb_service_get_rate_limit('geocoding'); SELECT cdb_dataservices_client.cdb_service_get_rate_limit('geocoder');
cdb_service_get_rate_limit cdb_service_get_rate_limit
--------------------------------- ---------------------------------
@@ -108,16 +108,18 @@ This functions doesn't return any value.
#### Example #### Example
This will configure the geocoding service rate limit for user `myusername`, a non-organization user. This will configure the geocoder service rate limit for user `myusername`, a non-organization user.
The limit will be set at 1000 requests per day. Since the user doesn't belong to any organization, The limit will be set at 1000 requests per day. Since the user doesn't belong to any organization,
`NULL` will be passed to the organization argument; otherwise the name of the user's organization should `NULL` will be passed to the organization argument; otherwise the name of the user's organization should
be provided. be provided.
Note that the name of the geocoding services is `geocoder` and not `geocoding`.
``` ```
SELECT cdb_dataservices_client.cdb_service_set_user_rate_limit( SELECT cdb_dataservices_client.cdb_service_set_user_rate_limit(
'myusername', 'myusername',
NULL, NULL,
'geocoding', 'geocoder',
'{"limit":1000,"period":86400}' '{"limit":1000,"period":86400}'
); );
@@ -140,7 +142,7 @@ This functions doesn't return any value.
#### Example #### Example
This will configure the geocoding service rate limit for the `myorg` organization. This will configure the geocoder service rate limit for the `myorg` organization.
The limit will be set at 100 requests per hour. The limit will be set at 100 requests per hour.
Note that even we're setting the default configuration for the whole organization, Note that even we're setting the default configuration for the whole organization,
the name of a user of the organization must be provided for technical reasons. the name of a user of the organization must be provided for technical reasons.
@@ -149,7 +151,7 @@ the name of a user of the organization must be provided for technical reasons.
SELECT cdb_dataservices_client.cdb_service_set_org_rate_limit( SELECT cdb_dataservices_client.cdb_service_set_org_rate_limit(
'myorgadmin', 'myorgadmin',
'myorg', 'myorg',
'geocoding', 'geocoder',
'{"limit":100,"period":3600}' '{"limit":100,"period":3600}'
); );
@@ -172,7 +174,7 @@ This functions doesn't return any value.
#### Example #### Example
This will configure the default geocoding service rate limit for all users This will configure the default geocoder service rate limit for all users
accesing the data-services server. accesing the data-services server.
The limit will be set at 10000 requests per month. The limit will be set at 10000 requests per month.
Note that even we're setting the default configuration for the server, Note that even we're setting the default configuration for the server,
@@ -183,7 +185,7 @@ must be provided for technical reasons.
SELECT cdb_dataservices_client.cdb_service_set_server_rate_limit( SELECT cdb_dataservices_client.cdb_service_set_server_rate_limit(
'myorgadmin', 'myorgadmin',
'myorg', 'myorg',
'geocoding', 'geocoder',
'{"limit":10000,"period":108000}' '{"limit":10000,"period":108000}'
); );