Skip to content

Commit

Permalink
Moved fireHit for GET and clear
Browse files Browse the repository at this point in the history
  • Loading branch information
evan-kenzan committed Apr 19, 2017
1 parent 58df361 commit 87a1652
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions applications/puzzle/common/models/crossword.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ var Etcd = require('node-etcd')
module.exports = function(Crossword) {

var etcd = new Etcd("http://example-etcd-cluster-client-service:2379");

fireHit();
Crossword.get = function(cb) {

var etcdPuzzleResp = etcd.getSync("puzzle");

if (etcdPuzzleResp && !etcdPuzzleResp.err) {

console.log(`Responding with cache`);
fireHit();

var cachedPuzzle = JSON.parse(etcdPuzzleResp.body.node.value);
cachedPuzzle.fromCache = true;
cb(null, cachedPuzzle);
} else {
Crossword.findOne(function(err, crossword) {

fireHit();

if(err) {
handleError(err.message, cb);
} else {
Expand Down Expand Up @@ -64,8 +64,9 @@ module.exports = function(Crossword) {
}

Crossword.clear = function(cb) {
fireHit();
Crossword.findOne(function(err, crossword) {
fireHit();

if(err) handleError(err.message, cb);
var updatedWords = [];
for (var i = 0; i < crossword.words.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions part3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ parts:
- cap: Now we will bootstrap the crossword/mongodb services, creating a docker image and storing it in the local registry. This script runs the same steps as before for a different service application.
com: scripts/puzzle.sh

- cap: Check to see if services has been deployed
com: kubectl rollout status deployment/services
- cap: Check to see if the puzzle service has been deployed
com: kubectl rollout status deployment/puzzle

- cap: Bootstrap the frontend web application. This script follows the same steps as before but
com: scripts/kr8sswordz-pages.sh
Expand Down
4 changes: 2 additions & 2 deletions steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ parts:
- cap: Now we will bootstrap the crossword/mongodb services, creating a docker image and storing it in the local registry. This script runs the same steps as before for a different service application.
com: scripts/puzzle.sh

- cap: Check to see if services has been deployed
com: kubectl rollout status deployment/services
- cap: Check to see if the puzzle service has been deployed
com: kubectl rollout status deployment/puzzle

- cap: Bootstrap the frontend web application. This script follows the same steps as before but
com: scripts/kr8sswordz-pages.sh
Expand Down

0 comments on commit 87a1652

Please sign in to comment.