Skip to content

Commit

Permalink
feat(valhalla): allow to configure exec timeout (#112)
Browse files Browse the repository at this point in the history
* Merge doc/translate in develop (#107)

* Test commit

* test commit

* test commit IDE

* First draft on english documentation

* Drafting the english doc

* second draft of doc

* Adding modifications from fr develop doc

* corrections de coquilles sur les liens

* corrections de coquilles sur les liens

* update coquilles liens

* test commit

* test commit IDE

* First draft on english documentation

* second draft of doc

* Adding modifications from fr develop doc

* update coquilles liens

* draft: main readme in english

* fix: main readme test

* fix typo test

* fix : finish rebase

* fix typo and switch to default french

* fix readme for introduction

---------

Co-authored-by: JRS <[email protected]>

* feat: handle exec maxBuffer size with environment variable

* feat: update changelog

* Changelog.md

* Bump version in package.json

* feat(valhalla): allow to configure exec timeout (#111)

* feat(valhalla): allow to configure exec timeout

* doc: add exec_tiemout description

* doc: update changelog

* Bump package.json

---------

Co-authored-by: lgrd <[email protected]>
Co-authored-by: JRS <[email protected]>
Co-authored-by: Matthieu Proboeuf <[email protected]>
Co-authored-by: Aurelien <[email protected]>
  • Loading branch information
5 people authored Dec 18, 2024
1 parent 93e9965 commit 32f8f38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 2.2.8
ADDED:
- Valhalla: allow to configure a timeout on valhalla_service exec

## 2.2.7
ADDED:
- Valhalla: Provide the ability to set maxBuffer in exec command options to avoid maxBuffer lenght exceeded error (#109)
Expand Down
4 changes: 4 additions & 0 deletions documentation/production/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,7 @@ Road2 peut être directement interrogé en HTTPS. Pour cela, il utilise le modul

Il est possible de changer la taille du buffer lors d'une source Valhalla en valorisant la variable d'environnement `EXEC_MAX_BUFFER_SIZE`.
La valeur par défaut est de 1MB.

### Gestion du timeout valhalla
Il est possible de changer la valeur du timeout d'execution du process valhalla_service en valorisant la variable d'environnement `EXEC_TIMEOUT` (nombre de millisecondes).
La valeur par défaut est `0` soit pas de timeout.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "road2",
"version": "2.2.7",
"version": "2.2.8",
"description": "Calcul d'itinéraire",
"author": "RDEV - IGN",
"main": "src/js/road2.js",
Expand Down
6 changes: 4 additions & 2 deletions src/js/sources/valhallaSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const log4js = require('log4js');
const LOGGER = log4js.getLogger("VALHALLASOURCE");
// Récupération de la valeur du maxBuffer en variable d'environment variable ou valorisation par défaut (1MB)
const maxBuffer = process.env.EXEC_MAX_BUFFER_SIZE ? parseInt(process.env.EXEC_MAX_BUFFER_SIZE, 10) : 1024 * 1024;
// Récupération de la valeur du timeout pour l'execution du valhalla_service en variable d'environnement ou valorisation par défaut (0)
const execTimeout = process.env.EXEC_TIMEOUT ? parseInt(process.env.EXEC_TIMEOUT, 10) : 0;

/**
*
Expand Down Expand Up @@ -188,7 +190,7 @@ module.exports = class valhallaSource extends Source {
// Permet de grandement se simplifier le parsing !!
const optionsString = `"directions_options":{"format":"osrm"}`;
const commandString = `valhalla_service ${this._configuration.storage.config} route '{${locationsString},${costingString},${optionsString}}' `;
const options = { maxBuffer: maxBuffer };
const options = { maxBuffer: maxBuffer, timeout: execTimeout };
LOGGER.info(commandString);

return new Promise( (resolve, reject) => {
Expand Down Expand Up @@ -290,7 +292,7 @@ module.exports = class valhallaSource extends Source {
const reverseString = `"reverse":${reverse}`;
const polygonsString = `"polygons":true`;
const commandString = `valhalla_service ${this._configuration.storage.config} isochrone '{${locationsString},${costingString},${costingOptionsString},${contoursString},${reverseString},${polygonsString}}' `;
const options = { maxBuffer: maxBuffer };
const options = { maxBuffer: maxBuffer, timeout: execTimeout };
LOGGER.info(commandString);

return new Promise( (resolve, reject) => {
Expand Down

0 comments on commit 32f8f38

Please sign in to comment.