Skip to content

Commit

Permalink
Improved short polling. Cached cluster data for 30mins with "forceRef…
Browse files Browse the repository at this point in the history
…resh" option. Externalised server-side defaults into environment-based configuration files.

UI:
- Implemented short polling logic - query the server up to 120 times with 5s intervals
- Added "Reload Server Cache" button to UI to force server to refresh cluster data.
- Upgraded bootstrap from v3.3.5 to v3.3.7 for glyphicons including "glyphicons-halflings-regular" fonts.
- Improved error handling.

Server:
- Externalised server-side defaults into environment-based configuration files.
- Added ClusterState & ClusterStateCache to cache cluster data.
- Added FetchStatus to represent current status of fetching cluster data.
- Improved error handling.
- Added test suite - run tests with "npm run test"
  • Loading branch information
mattcallanan committed May 21, 2018
1 parent a239748 commit 4ec2c72
Show file tree
Hide file tree
Showing 29 changed files with 1,372 additions and 141 deletions.
Binary file added ClientServerInteraction-SequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions ClientServerInteraction-SequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@startuml
skinparam sequenceArrowThickness 2
skinparam roundcorner 20
skinparam maxmessagesize 60
skinparam sequenceParticipant underline

actor User
participant "Browser" as A
participant "Request" as B
participant "Background Processing" as C
participant "ClusterStateCache" as D

activate D

User -> A: Select Cluster
activate A

A -> B: "/api/instance_summaries_with_tasks"
activate B

B -> C: Get State
activate C
C -> D: Create
activate D
C -> D: INITIAL
C --> B: INITIAL

B --> A: INITIAL
deactivate B

C -> D: FETCHING

A -> B: "/api/instance_summaries_with_tasks"
activate B
B -> C: Get State
C --> B: FETCHING
B --> A: FETCHING
deactivate B

C -> D: FETCHED

A -> B: "/api/instance_summaries_with_tasks"
activate B
B -> C: Get State
C --> B: FETCHED
B --> A: FETCHED
deactivate B

D -> D : Expire
deactivate D

A --> User: Render Graph
deactivate A


deactivate C
deactivate D

@enduml
38 changes: 38 additions & 0 deletions FetchStatus-StateDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@startuml

'[*] --> null
[*] --> INITIAL
INITIAL --> FETCHING
FETCHING --> FETCHED
'INITIAL --> null : Expired
'FETCHING --> null : Expired
'FETCHED --> null : Expired
'ERROR --> null : Expired
INITIAL --> ERROR : Failed
FETCHING --> ERROR : Failed
FETCHED --> ERROR : Failed

'FETCHED --> [*] : Success
'ERROR --> [*] : Error

@enduml

@startuml

[*] --> null
null --> INITIAL
INITIAL --> FETCHING
FETCHING --> FETCHED
INITIAL --> null : Expired
FETCHING --> null : Expired
FETCHED --> null : Expired
ERROR --> null : Expired
INITIAL --> ERROR
FETCHING --> ERROR
FETCHED --> ERROR

'FETCHED --> [*] : Success
'ERROR --> [*] : Error

@enduml

Binary file added FetchStatus-StateDiagram1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added FetchStatus-StateDiagram2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
var app = require('../app');
var debug = require('debug')('c3vis:server');
var http = require('http');
var config = require('../config/config');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
var port = normalizePort(config.port);
app.set('port', port);

/**
Expand Down
11 changes: 11 additions & 0 deletions config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const _ = require('lodash');

// Assume running in 'dev' environment if NODE_ENV environment variable not defined
const targetEnvironment = (process.env.NODE_ENV || 'dev');

// Load default configuration from defaults.js
// and extend with environment-specific configuration
module.exports = _.merge(
require('./defaults.js'),
require(`./env/${targetEnvironment}.js`) || {}
);
14 changes: 14 additions & 0 deletions config/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
port: process.env.PORT || 3000,
clusterStateCacheTtl: 30 * 60 * 1000, // Invalidate clusters in cache after 30 minutes
aws: {
configFile: './aws_config.json',
apiDelay: 100, // milliseconds to pause between AWS API calls to prevent API rate limiting
listInstancesPageSize: 100, // max 100
describeInstancesPageSize: 100, // max 100
listTasksPageSize: 100, // max 100
describeTasksPageSize: 100, // max 100
maxSimultaneousDescribeTasksCalls: 2,
maxSimultaneousDescribeTaskDefinitionCalls: 1,
}
};
3 changes: 3 additions & 0 deletions config/env/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
// add dev environment config overrides here and enable at startup with NODE_ENV=dev environment variable
};
3 changes: 3 additions & 0 deletions config/env/prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
// add production environment config overrides here and enable at startup with NODE_ENV=prod environment variable
};
3 changes: 3 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
// add test environment config overrides here and enable at startup with NODE_ENV=test environment variable
};
Loading

0 comments on commit 4ec2c72

Please sign in to comment.