From 4cf2db516d0ed22abe147c08271c6ffe191c49e7 Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Fri, 4 Aug 2017 08:49:44 +0200 Subject: [PATCH 1/8] added EurekaHealthStatus component & documentation --- README.md | 24 +++++ components/widgets/eureka/health-status.js | 113 +++++++++++++++++++++ 2 files changed, 137 insertions(+) create mode 100644 components/widgets/eureka/health-status.js diff --git a/README.md b/README.md index 31680e7b..264af795 100644 --- a/README.md +++ b/README.md @@ -312,6 +312,30 @@ import GitHubIssueCount from '../components/github/issue-count' * `repository`: Name of the repository * `authKey`: Credential key, defined in [auth.js](./auth.js) +### [Eureka Health Status](./components/widgets/eureka/health-status.js) + +#### Example + +```javascript +import EurekaHealthStatus from '../components/widgets/eureka/health-status' + + +``` + +#### props + +* `title`: Widget title (Default: `GitHub Issue Count`) +* `interval`: Refresh interval in milliseconds (Default: `300000`) +* `url`: Eureka Server Base URL +* `healthQuery`: Relative Path to Spring Boot Actuator Health endpoint +* `appsQuery`: Relative Path to Eureka Apps API endpoint [Eureka REST operations](https://github.com/Netflix/eureka/wiki/Eureka-REST-operations) +* `authKey`: Credential key, defined in [auth.js](./auth.js) + ## Available Themes ### [light](./styles/light-theme.js) diff --git a/components/widgets/eureka/health-status.js b/components/widgets/eureka/health-status.js new file mode 100644 index 00000000..cd6e9cf7 --- /dev/null +++ b/components/widgets/eureka/health-status.js @@ -0,0 +1,113 @@ +import { Component } from 'react' +import fetch from 'isomorphic-unfetch' +import yup from 'yup' +import Widget from '../../widget' +import { basicAuthHeader } from '../../../lib/auth' +import styled from 'styled-components' + +const schema = yup.object().shape({ + url: yup.string().url().required(), + interval: yup.number(), + appsQuery: yup.string(), + healthQuery: yup.string(), + title: yup.string(), + authKey: yup.string() +}) + +const EurekaDiv = styled.div` + background-color: ${props => props.hasError ? props.theme.palette.errorColor : props.theme.palette.canvasColor} +`; + +export default class EurekaHealthStatus extends Component { + static defaultProps = { + interval: 1000 * 60 * 60, + title: 'Eureka Health Status' + } + + state = { + days: 0, + error: false, + loading: true + } + + componentDidMount () { + schema.validate(this.props) + .then(() => this.fetchInformation()) + .catch((err) => { + console.error(`${err.name} @ ${this.constructor.name}`, err.errors) + this.setState({ error: true, loading: false }) + }) + } + + componentWillUnmount () { + clearInterval(this.interval) + } + + mapStatus (status) { + let hasError = true + + if ( status === 'UP' ) { + hasError = false; + } + + return hasError + } + + async fetchInformation () { + const { authKey, url, healthQuery, appsQuery } = this.props + let opts = authKey ? { headers: basicAuthHeader(authKey) } : {} + + try { + const res = await fetch(`${url}${healthQuery}`, opts) + const json = await res.json() + + let hasError = this.mapStatus(json.status) + let statusLine1 = '' + let statusLine2 = '' + + if (hasError === false) { + opts = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} + try { + const resApps = await fetch(`${url}${appsQuery}`, opts) + const jsonApps = await resApps.json() + + if (jsonApps.applications.apps__hashcode.includes('DOWN') === true) { + hasError = true + } else { + hasError = false + } + + const appsStatus = jsonApps.applications.apps__hashcode.split('_') + if ( appsStatus.length > 0 && appsStatus.length < 4 ) { + statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` + statusLine2 = '' + } else { + statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` + statusLine2 = `${appsStatus[2]}: ${appsStatus[3]}` + } + } catch (error) { + hasError = true + } + } + + this.setState({ statusLine1: statusLine1, statusLine2: statusLine2, hasError: hasError, error: false, loading: false }) + } catch (error) { + this.setState({ error: true, loading: false }) + } finally { + this.interval = setInterval(() => this.fetchInformation(), this.props.interval) + } + } + + render () { + const { days, error, loading, statusLine1, statusLine2, hasError } = this.state + const { title } = this.props + return ( + + + {statusLine1} + {statusLine2} + + + ) + } +} From 156c2367b0ff8d8871eae7b98071064ec4378aa5 Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Sat, 23 Sep 2017 13:11:53 +0200 Subject: [PATCH 2/8] check instance-count of services --- README.md | 4 ++++ components/widgets/eureka/health-status.js | 17 +++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 264af795..5b2ef98b 100644 --- a/README.md +++ b/README.md @@ -324,6 +324,8 @@ import EurekaHealthStatus from '../components/widgets/eureka/health-status' url='http://127.0.0.1:8080/http://eurekahost:8761' healthQuery='/management/health' appsQuery='/eureka/apps' + appNamePattern='SERVICE-X' + minimumInstances={2} /> ``` @@ -335,6 +337,8 @@ import EurekaHealthStatus from '../components/widgets/eureka/health-status' * `healthQuery`: Relative Path to Spring Boot Actuator Health endpoint * `appsQuery`: Relative Path to Eureka Apps API endpoint [Eureka REST operations](https://github.com/Netflix/eureka/wiki/Eureka-REST-operations) * `authKey`: Credential key, defined in [auth.js](./auth.js) +* `appNamePattern`: Name pattern the service-names have to start with +* `minimumInstances`: Number of instances for each service which are expected to run to be fine ## Available Themes diff --git a/components/widgets/eureka/health-status.js b/components/widgets/eureka/health-status.js index cd6e9cf7..edec9ec1 100644 --- a/components/widgets/eureka/health-status.js +++ b/components/widgets/eureka/health-status.js @@ -11,6 +11,8 @@ const schema = yup.object().shape({ appsQuery: yup.string(), healthQuery: yup.string(), title: yup.string(), + minimumInstances: yup.number(), + appNamePattern: yup.string(), authKey: yup.string() }) @@ -21,7 +23,9 @@ const EurekaDiv = styled.div` export default class EurekaHealthStatus extends Component { static defaultProps = { interval: 1000 * 60 * 60, - title: 'Eureka Health Status' + title: 'Eureka Health Status', + minimumInstances: 2, + appNamePattern: '' } state = { @@ -54,7 +58,7 @@ export default class EurekaHealthStatus extends Component { } async fetchInformation () { - const { authKey, url, healthQuery, appsQuery } = this.props + const { authKey, url, healthQuery, appsQuery, appNamePattern, minimumInstances } = this.props let opts = authKey ? { headers: basicAuthHeader(authKey) } : {} try { @@ -85,6 +89,15 @@ export default class EurekaHealthStatus extends Component { statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` statusLine2 = `${appsStatus[2]}: ${appsStatus[3]}` } + + jsonApps.applications.application.forEach (function(entry) { + if ( entry.name.startsWith(appNamePattern) && entry.instance.length < minimumInstances) { + console.log(entry.name + ' - ' + entry.instance.length) + hasError = true + statusLine2 += entry.name + ' ' + } + }); + } catch (error) { hasError = true } From 6844d6a1c805d20d5140d69d70166962509dd29b Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Sat, 23 Sep 2017 13:24:17 +0200 Subject: [PATCH 3/8] fixed standard sytle issues --- components/widgets/eureka/health-status.js | 23 +++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/components/widgets/eureka/health-status.js b/components/widgets/eureka/health-status.js index edec9ec1..f961d9bd 100644 --- a/components/widgets/eureka/health-status.js +++ b/components/widgets/eureka/health-status.js @@ -16,9 +16,9 @@ const schema = yup.object().shape({ authKey: yup.string() }) -const EurekaDiv = styled.div` - background-color: ${props => props.hasError ? props.theme.palette.errorColor : props.theme.palette.canvasColor} -`; +const EurekaDiv = styled.div` + background-color: ${props => props.hasError ? props.theme.palette.errorColor : props.theme.palette.canvasColor}; +` export default class EurekaHealthStatus extends Component { static defaultProps = { @@ -50,8 +50,8 @@ export default class EurekaHealthStatus extends Component { mapStatus (status) { let hasError = true - if ( status === 'UP' ) { - hasError = false; + if (status === 'UP') { + hasError = false } return hasError @@ -70,7 +70,7 @@ export default class EurekaHealthStatus extends Component { let statusLine2 = '' if (hasError === false) { - opts = { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} + opts = {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} try { const resApps = await fetch(`${url}${appsQuery}`, opts) const jsonApps = await resApps.json() @@ -82,7 +82,7 @@ export default class EurekaHealthStatus extends Component { } const appsStatus = jsonApps.applications.apps__hashcode.split('_') - if ( appsStatus.length > 0 && appsStatus.length < 4 ) { + if (appsStatus.length > 0 && appsStatus.length < 4) { statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` statusLine2 = '' } else { @@ -90,14 +90,13 @@ export default class EurekaHealthStatus extends Component { statusLine2 = `${appsStatus[2]}: ${appsStatus[3]}` } - jsonApps.applications.application.forEach (function(entry) { - if ( entry.name.startsWith(appNamePattern) && entry.instance.length < minimumInstances) { + jsonApps.applications.application.forEach(function (entry) { + if (entry.name.startsWith(appNamePattern) && entry.instance.length < minimumInstances) { console.log(entry.name + ' - ' + entry.instance.length) hasError = true statusLine2 += entry.name + ' ' } - }); - + }) } catch (error) { hasError = true } @@ -112,7 +111,7 @@ export default class EurekaHealthStatus extends Component { } render () { - const { days, error, loading, statusLine1, statusLine2, hasError } = this.state + const { error, loading, statusLine1, statusLine2, hasError } = this.state const { title } = this.props return ( From ff56d2142a3c4d92bec641dd470a424a8e2734a4 Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Thu, 28 Sep 2017 21:14:14 +0200 Subject: [PATCH 4/8] refactoring & app instance health check --- README.md | 5 +- components/widgets/eureka/health-status.js | 95 ++++++++++++++++------ 2 files changed, 74 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 5b2ef98b..9bef0ccc 100644 --- a/README.md +++ b/README.md @@ -321,10 +321,11 @@ import EurekaHealthStatus from '../components/widgets/eureka/health-status' ``` diff --git a/components/widgets/eureka/health-status.js b/components/widgets/eureka/health-status.js index f961d9bd..626c74b2 100644 --- a/components/widgets/eureka/health-status.js +++ b/components/widgets/eureka/health-status.js @@ -2,14 +2,16 @@ import { Component } from 'react' import fetch from 'isomorphic-unfetch' import yup from 'yup' import Widget from '../../widget' +import Table, { Th, Td } from '../../table' import { basicAuthHeader } from '../../../lib/auth' import styled from 'styled-components' const schema = yup.object().shape({ url: yup.string().url().required(), interval: yup.number(), - appsQuery: yup.string(), - healthQuery: yup.string(), + baseQuery: yup.string().required(), + appsQuery: yup.string().required(), + healthQuery: yup.string().required(), title: yup.string(), minimumInstances: yup.number(), appNamePattern: yup.string(), @@ -36,43 +38,72 @@ export default class EurekaHealthStatus extends Component { componentDidMount () { schema.validate(this.props) - .then(() => this.fetchInformation()) - .catch((err) => { - console.error(`${err.name} @ ${this.constructor.name}`, err.errors) - this.setState({ error: true, loading: false }) - }) + .then(() => this.fetchInformation()) + .catch((err) => { + console.error(`${err.name} @ ${this.constructor.name}`, err.errors) + this.setState({ error: true, loading: false }) + }) } componentWillUnmount () { clearInterval(this.interval) } - mapStatus (status) { + mapHealthStatus (status) { let hasError = true - if (status === 'UP') { hasError = false } + return hasError + } + + checkInstanceCount (minimumInstances, appNamePattern, appList) { + let hasError = false + appList.forEach(function (entry) { + if (entry.name.startsWith(appNamePattern) && entry.instance.length < minimumInstances) { + hasError = true + } + }) + return hasError + } + async checkInstanceHealth (url, appNamePattern, appList) { + let hasError = false + for (var i = 0; i < appList.length; i++) { + const app = appList[i] + if (app.name.startsWith(appNamePattern)) { + for (var j = 0; j < app.instance.length; j++) { + try { + const curInstance = app.instance[j] + let opts = {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} + const resHealth = await fetch(url + curInstance.healthCheckUrl, opts) + const healthJson = await resHealth.json() + hasError = this.mapHealthStatus(healthJson.status) + } catch (error) { + hasError = true + } + } + } + } return hasError } async fetchInformation () { - const { authKey, url, healthQuery, appsQuery, appNamePattern, minimumInstances } = this.props + const { authKey, url, baseQuery, healthQuery, appsQuery, appNamePattern, minimumInstances } = this.props let opts = authKey ? { headers: basicAuthHeader(authKey) } : {} try { - const res = await fetch(`${url}${healthQuery}`, opts) + const res = await fetch(`${url}${baseQuery}${healthQuery}`, opts) const json = await res.json() - let hasError = this.mapStatus(json.status) + let hasError = this.mapHealthStatus(json.status) let statusLine1 = '' let statusLine2 = '' if (hasError === false) { opts = {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} try { - const resApps = await fetch(`${url}${appsQuery}`, opts) + const resApps = await fetch(`${url}${baseQuery}${appsQuery}`, opts) const jsonApps = await resApps.json() if (jsonApps.applications.apps__hashcode.includes('DOWN') === true) { @@ -84,24 +115,30 @@ export default class EurekaHealthStatus extends Component { const appsStatus = jsonApps.applications.apps__hashcode.split('_') if (appsStatus.length > 0 && appsStatus.length < 4) { statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` - statusLine2 = '' } else { statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` - statusLine2 = `${appsStatus[2]}: ${appsStatus[3]}` + statusLine1 += ` - ${appsStatus[2]}: ${appsStatus[3]}` } - jsonApps.applications.application.forEach(function (entry) { - if (entry.name.startsWith(appNamePattern) && entry.instance.length < minimumInstances) { - console.log(entry.name + ' - ' + entry.instance.length) - hasError = true - statusLine2 += entry.name + ' ' + if (hasError === false) { + hasError = await this.checkInstanceCount(minimumInstances, appNamePattern, jsonApps.applications.application) + if (hasError === true) { + statusLine2 = 'Instance redundancy failed' } - }) + } + + if (hasError === false) { + hasError = await this.checkInstanceHealth(url, appNamePattern, jsonApps.applications.application) + if (hasError === true) { + statusLine2 = 'App health check failed' + } + } } catch (error) { hasError = true } + } else { + statusLine2 = 'Eureka health failed' } - this.setState({ statusLine1: statusLine1, statusLine2: statusLine2, hasError: hasError, error: false, loading: false }) } catch (error) { this.setState({ error: true, loading: false }) @@ -116,8 +153,18 @@ export default class EurekaHealthStatus extends Component { return ( - {statusLine1} - {statusLine2} + + + + + + + + + + + +
Apps{statusLine1}
Info{statusLine2}
) From 6c33822059022d02db6c0dd16be6be14c8632f0b Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Thu, 28 Sep 2017 21:18:31 +0200 Subject: [PATCH 5/8] readme added eureka health status to index --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9bef0ccc..ba7ed9ea 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,7 @@ * [SonarQube](#sonarqube) * [Elasticsearch Hit Count](#elasticsearch-hit-count) * [GitHub Issue Count](#github-issue-count) + * [Eureka Health Status](#eureka-health-status) * [Available Themes](#available-themes) * [light](#light) * [dark](#dark) From 805c89d45e7c58b27d8130ebe539c49ff34eaa17 Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Fri, 6 Oct 2017 09:13:54 +0200 Subject: [PATCH 6/8] use clear veriable names, code cleanup --- components/widgets/eureka/health-status.js | 49 +++++++++------------- 1 file changed, 20 insertions(+), 29 deletions(-) diff --git a/components/widgets/eureka/health-status.js b/components/widgets/eureka/health-status.js index 626c74b2..89fc48cb 100644 --- a/components/widgets/eureka/health-status.js +++ b/components/widgets/eureka/health-status.js @@ -31,9 +31,10 @@ export default class EurekaHealthStatus extends Component { } state = { - days: 0, error: false, - loading: true + loading: true, + appStatus: '', + infoMessage: '' } componentDidMount () { @@ -49,14 +50,6 @@ export default class EurekaHealthStatus extends Component { clearInterval(this.interval) } - mapHealthStatus (status) { - let hasError = true - if (status === 'UP') { - hasError = false - } - return hasError - } - checkInstanceCount (minimumInstances, appNamePattern, appList) { let hasError = false appList.forEach(function (entry) { @@ -78,7 +71,7 @@ export default class EurekaHealthStatus extends Component { let opts = {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} const resHealth = await fetch(url + curInstance.healthCheckUrl, opts) const healthJson = await resHealth.json() - hasError = this.mapHealthStatus(healthJson.status) + hasError = healthJson.status !== 'UP' } catch (error) { hasError = true } @@ -96,50 +89,47 @@ export default class EurekaHealthStatus extends Component { const res = await fetch(`${url}${baseQuery}${healthQuery}`, opts) const json = await res.json() - let hasError = this.mapHealthStatus(json.status) - let statusLine1 = '' - let statusLine2 = '' + let appStatus = '' + let infoMessage = '' + let hasError = json.status !== 'UP' if (hasError === false) { opts = {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} + try { const resApps = await fetch(`${url}${baseQuery}${appsQuery}`, opts) const jsonApps = await resApps.json() - if (jsonApps.applications.apps__hashcode.includes('DOWN') === true) { - hasError = true - } else { - hasError = false - } + hasError = jsonApps.applications.apps__hashcode.includes('DOWN') const appsStatus = jsonApps.applications.apps__hashcode.split('_') if (appsStatus.length > 0 && appsStatus.length < 4) { - statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` + appStatus = `${appsStatus[0]}: ${appsStatus[1]}` } else { - statusLine1 = `${appsStatus[0]}: ${appsStatus[1]}` - statusLine1 += ` - ${appsStatus[2]}: ${appsStatus[3]}` + appStatus = `${appsStatus[0]}: ${appsStatus[1]}` + appStatus += ` - ${appsStatus[2]}: ${appsStatus[3]}` } if (hasError === false) { hasError = await this.checkInstanceCount(minimumInstances, appNamePattern, jsonApps.applications.application) if (hasError === true) { - statusLine2 = 'Instance redundancy failed' + infoMessage = 'Instance redundancy failed' } } if (hasError === false) { hasError = await this.checkInstanceHealth(url, appNamePattern, jsonApps.applications.application) if (hasError === true) { - statusLine2 = 'App health check failed' + infoMessage = 'App health check failed' } } } catch (error) { hasError = true } } else { - statusLine2 = 'Eureka health failed' + infoMessage = 'Eureka health failed' } - this.setState({ statusLine1: statusLine1, statusLine2: statusLine2, hasError: hasError, error: false, loading: false }) + this.setState({ appStatus, infoMessage, hasError, error: false, loading: false }) } catch (error) { this.setState({ error: true, loading: false }) } finally { @@ -148,8 +138,9 @@ export default class EurekaHealthStatus extends Component { } render () { - const { error, loading, statusLine1, statusLine2, hasError } = this.state + const { error, loading, appStatus, infoMessage, hasError } = this.state const { title } = this.props + return ( @@ -157,11 +148,11 @@ export default class EurekaHealthStatus extends Component { Apps - {statusLine1} + {appStatus} Info - {statusLine2} + {infoMessage} From 1dc131993bda9eae76dc2dcaf12fb0b0dc9e17ce Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Thu, 12 Oct 2017 20:18:48 +0200 Subject: [PATCH 7/8] fixed review format issues, completed README --- README.md | 13 ++++---- components/widgets/eureka/health-status.js | 36 +++++++++++++--------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index ba7ed9ea..e54e380b 100644 --- a/README.md +++ b/README.md @@ -321,9 +321,9 @@ import GitHubIssueCount from '../components/github/issue-count' import EurekaHealthStatus from '../components/widgets/eureka/health-status' this.fetchInformation()) @@ -47,13 +52,14 @@ export default class EurekaHealthStatus extends Component { } componentWillUnmount () { - clearInterval(this.interval) + clearTimeout(this.timeout) } - checkInstanceCount (minimumInstances, appNamePattern, appList) { + checkInstanceCount (appList) { + const { appNamePattern, minimumInstances } = this.props let hasError = false appList.forEach(function (entry) { - if (entry.name.startsWith(appNamePattern) && entry.instance.length < minimumInstances) { + if ((appNamePattern.length === 0 || entry.name.startsWith(appNamePattern)) && entry.instance.length < minimumInstances) { hasError = true } }) @@ -64,7 +70,7 @@ export default class EurekaHealthStatus extends Component { let hasError = false for (var i = 0; i < appList.length; i++) { const app = appList[i] - if (app.name.startsWith(appNamePattern)) { + if (appNamePattern.length === 0 || app.name.startsWith(appNamePattern)) { for (var j = 0; j < app.instance.length; j++) { try { const curInstance = app.instance[j] @@ -82,22 +88,22 @@ export default class EurekaHealthStatus extends Component { } async fetchInformation () { - const { authKey, url, baseQuery, healthQuery, appsQuery, appNamePattern, minimumInstances } = this.props + const { authKey, url, eurekaQuery, healthQuery, appsQuery, appNamePattern } = this.props let opts = authKey ? { headers: basicAuthHeader(authKey) } : {} try { - const res = await fetch(`${url}${baseQuery}${healthQuery}`, opts) + const res = await fetch(`${url}${eurekaQuery}${healthQuery}`, opts) const json = await res.json() let appStatus = '' let infoMessage = '' let hasError = json.status !== 'UP' - if (hasError === false) { + if (!hasError) { opts = {headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }} try { - const resApps = await fetch(`${url}${baseQuery}${appsQuery}`, opts) + const resApps = await fetch(`${url}${eurekaQuery}${appsQuery}`, opts) const jsonApps = await resApps.json() hasError = jsonApps.applications.apps__hashcode.includes('DOWN') @@ -110,16 +116,16 @@ export default class EurekaHealthStatus extends Component { appStatus += ` - ${appsStatus[2]}: ${appsStatus[3]}` } - if (hasError === false) { - hasError = await this.checkInstanceCount(minimumInstances, appNamePattern, jsonApps.applications.application) - if (hasError === true) { + if (!hasError) { + hasError = this.checkInstanceCount(jsonApps.applications.application) + if (hasError) { infoMessage = 'Instance redundancy failed' } } - if (hasError === false) { + if (!hasError) { hasError = await this.checkInstanceHealth(url, appNamePattern, jsonApps.applications.application) - if (hasError === true) { + if (hasError) { infoMessage = 'App health check failed' } } @@ -133,7 +139,7 @@ export default class EurekaHealthStatus extends Component { } catch (error) { this.setState({ error: true, loading: false }) } finally { - this.interval = setInterval(() => this.fetchInformation(), this.props.interval) + this.timeout = setTimeout(() => this.fetchInformation(), this.props.interval) } } From d61a35460222de31b357b313d03857930f5eafee Mon Sep 17 00:00:00 2001 From: Michael Bartsch Date: Thu, 12 Oct 2017 20:20:48 +0200 Subject: [PATCH 8/8] fixed review format issues & README --- README.md | 2 +- components/widgets/eureka/health-status.js | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e54e380b..f3c27ab1 100644 --- a/README.md +++ b/README.md @@ -333,7 +333,7 @@ import EurekaHealthStatus from '../components/widgets/eureka/health-status' #### props -* `title`: Widget title (Default: `GitHub Issue Count`) +* `title`: Widget title (Default: `Eureka Health Status`) * `interval`: Refresh interval in milliseconds (Default: `360000`) * `url`: Cross Origin Service URL * `eurekaQuery`: Eureka Server URL diff --git a/components/widgets/eureka/health-status.js b/components/widgets/eureka/health-status.js index 807f5c0d..6aa39a6b 100644 --- a/components/widgets/eureka/health-status.js +++ b/components/widgets/eureka/health-status.js @@ -112,8 +112,7 @@ export default class EurekaHealthStatus extends Component { if (appsStatus.length > 0 && appsStatus.length < 4) { appStatus = `${appsStatus[0]}: ${appsStatus[1]}` } else { - appStatus = `${appsStatus[0]}: ${appsStatus[1]}` - appStatus += ` - ${appsStatus[2]}: ${appsStatus[3]}` + appStatus = `${appsStatus[0]}: ${appsStatus[1]} - ${appsStatus[2]}: ${appsStatus[3]}` } if (!hasError) {