-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pod-priority
- Loading branch information
Showing
28 changed files
with
292 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,8 @@ objects: | |
requests: | ||
cpu: 10m | ||
memory: 10Mi | ||
limits: | ||
memory: 8Gi | ||
test: false | ||
triggers: | ||
- type: ConfigChange |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,8 @@ objects: | |
requests: | ||
cpu: 10m | ||
memory: 10Mi | ||
limits: | ||
memory: 8Gi | ||
test: false | ||
triggers: | ||
- type: ConfigChange |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const { | ||
Transport: LokkaTransportHttp, | ||
} = require('@lagoon/lokka-transport-http'); | ||
const fetchUrl = require('node-fetch'); | ||
|
||
class NetworkError extends Error {} | ||
class ApiError extends Error {} | ||
|
||
// Retries the fetch if operational/network errors occur | ||
const retryFetch = (endpoint, options, retriesLeft = 5, interval = 1000) => | ||
new Promise((resolve, reject) => | ||
fetchUrl(endpoint, options) | ||
.then(response => { | ||
if (response.status !== 200 && response.status !== 400) { | ||
throw new NetworkError(`Invalid status code: ${response.status}`); | ||
} | ||
|
||
return response.json(); | ||
}) | ||
.then(({ data, errors }) => { | ||
if (errors) { | ||
const error = new ApiError(`GraphQL Error: ${errors[0].message}`); | ||
error.rawError = errors; | ||
error.rawData = data; | ||
throw error; | ||
} | ||
|
||
resolve(data); | ||
}) | ||
.catch(error => { | ||
// Don't retry if limit is reached or the error was not network/operational | ||
if (retriesLeft === 1 || error instanceof ApiError) { | ||
reject(error); | ||
return; | ||
} | ||
|
||
setTimeout(() => { | ||
retryFetch(endpoint, options, retriesLeft - 1).then(resolve, reject); | ||
}, interval); | ||
}), | ||
); | ||
|
||
class Transport extends LokkaTransportHttp { | ||
constructor(endpoint, options = {}) { | ||
super(endpoint, options); | ||
} | ||
|
||
send(query, variables, operationName) { | ||
const payload = { query, variables, operationName }; | ||
const options = this._buildOptions(payload); | ||
|
||
return retryFetch(this.endpoint, options); | ||
} | ||
} | ||
|
||
module.exports = { | ||
Transport, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.