Skip to content

Commit

Permalink
Sync!
Browse files Browse the repository at this point in the history
  • Loading branch information
igoramadas committed Feb 21, 2017
1 parent 991dea4 commit 225d7be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions plugins/metrics/index.coffee
Expand Up @@ -61,8 +61,8 @@ class Metrics
# @param {Object} data Additional info about the current metric (URL data, for example).
# @return {Object} Returns the metric object to be used later on `end`.
start: (id, data) ->
return logger.notEnabled "Metrics", "start" if not settings.metrics.enabled
logger.debug "Metrics.start", obj, data
return logger.notEnabled "Metrics", "start" if not settings.metrics.enabled

obj = {}
obj.id = id
Expand Down Expand Up @@ -93,9 +93,8 @@ class Metrics
# Clean collected metrics by removing data older than X minutes (defined on settings).
# Please note that this runs on s schedule so you shouldn't need to call it manually, in most cases.
cleanup: ->
return logger.notEnabled "Metrics", "cleanup" if not settings.metrics.enabled

logger.debug "Metrics.cleanup"
return logger.notEnabled "Metrics", "cleanup" if not settings.metrics.enabled

now = moment().valueOf()
keyCounter = 0
Expand Down
6 changes: 6 additions & 0 deletions plugins/sockets/index.coffee
Expand Up @@ -49,6 +49,8 @@ class Sockets
# @param {Object} options Sockets init options.
# @option options {Object} server The Express server object to bind to.
bind: (server) =>
return logger.notEnabled "Sockets", "bind" if not settings.sockets.enabled

@io = require("socket.io") server

# Listen to user connection count updates.
Expand All @@ -67,6 +69,8 @@ class Sockets
# @param {String} key The event key.
# @param {Object} data The JSON data to be sent out to clients.
emit: (key, data) =>
return logger.notEnabled "Sockets", "emit" if not settings.sockets.enabled

if not @io?
logger.error "Sockets.emit", key, JSON.stringify(data).length + " bytes", "Sockets not initiated yet, abort!"
throw new Error "Sockets not initiated (@io is not set)."
Expand All @@ -81,6 +85,8 @@ class Sockets
# @param {Method} callback The callback to be called when key is triggered.
# @param {Boolean} onlyNewClients Optional, if true, listen to event only from new clients.
listenTo: (key, callback, onlyNewClients) =>
return logger.notEnabled "Sockets", "listenTo" if not settings.sockets.enabled

if not @io?.sockets?
logger.error "Sockets.listenTo", key, "Sockets not initiated yet, abort!"
throw new Error "Sockets not initiated (@io is not set)."
Expand Down

0 comments on commit 225d7be

Please sign in to comment.