Spelling & other various fixes.
This commit is contained in:
parent
3dc0066e06
commit
8ae8e99b25
@ -2,11 +2,11 @@
|
||||
|
||||
#=====================================================================
|
||||
|
||||
# It may be necessary to run XO-Server as a priviledged user (e.g.
|
||||
# It may be necessary to run XO-Server as a privileged user (e.g.
|
||||
# `root`) for instance to allow the HTTP server to listen on a
|
||||
# [priviledged ports](http://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html).
|
||||
# [privileged ports](http://www.w3.org/Daemon/User/Installation/PrivilegedPorts.html).
|
||||
#
|
||||
# To avoid security issues, XO-Server can drop its priviledges by
|
||||
# To avoid security issues, XO-Server can drop its privileges by
|
||||
# changing the user and the group is running with.
|
||||
#
|
||||
# Note: XO-Server will change them just after reading the
|
||||
|
@ -107,7 +107,7 @@ class $MappedCollection
|
||||
# The default function uses the index if the generator collection
|
||||
# is an array or the property name if it is an object.
|
||||
#
|
||||
# /!\: This entry MUST be overriden in rules for new items.
|
||||
# /!\: This entry MUST be overridden in rules for new items.
|
||||
if spec.key?
|
||||
@_key = spec.key
|
||||
throw new Error 'key must be a function' unless $_.isFunction @_key
|
||||
@ -124,13 +124,13 @@ class $MappedCollection
|
||||
# enters, exists or is updated.
|
||||
@_hooks = {}
|
||||
|
||||
# Initialy the collection is empty.
|
||||
# Initially the collection is empty.
|
||||
@_byKey = {}
|
||||
|
||||
# For performance concerns, items are also categorized by rules.
|
||||
@_byRule = {}
|
||||
|
||||
# Rules are checked for conformity and created in the sytem.
|
||||
# Rules are checked for conformity and created in the system.
|
||||
for name, def of spec.rules
|
||||
# If it's a function, runs it.
|
||||
def = def() if $_.isFunction def
|
||||
@ -187,8 +187,8 @@ class $MappedCollection
|
||||
|
||||
# Browse the value searching for dynamic properties/entries.
|
||||
#
|
||||
# An immediatly invoked function is used to easily handle
|
||||
# recursivity.
|
||||
# An immediately invoked function is used to easily handle
|
||||
# recursion.
|
||||
browse = (value, path) =>
|
||||
|
||||
# Unless the value is an object, there is nothing to browse.
|
||||
|
@ -226,7 +226,7 @@ Api.fn.session = {
|
||||
return null;
|
||||
}
|
||||
|
||||
var user = $waitPromise(this.xo.users.first(user_id))
|
||||
var user = $waitPromise(this.xo.users.first(user_id));
|
||||
|
||||
return _.pick(user.properties, 'id', 'email', 'permission');
|
||||
}),
|
||||
|
@ -35,7 +35,7 @@ Collection.prototype.add = function (models, options) {
|
||||
var error = model.validate();
|
||||
if (undefined !== error)
|
||||
{
|
||||
// @todo Better system inspired by Backbone.js.
|
||||
// TODO: Better system inspired by Backbone.js.
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ Collection.prototype.remove = function (ids) {
|
||||
* - Removes missing models.
|
||||
*/
|
||||
// Collection.prototype.set = function (/*models*/) {
|
||||
// // @todo
|
||||
// // TODO:
|
||||
// };
|
||||
|
||||
/**
|
||||
@ -141,7 +141,7 @@ Collection.prototype.update = function (models) {
|
||||
|
||||
if ( !(model instanceof this.model) )
|
||||
{
|
||||
// @todo Problems, we may be mixing in some default
|
||||
// TODO: Problems, we may be mixing in some default
|
||||
// properties which will overwrite existing ones.
|
||||
model = new this.model(model);
|
||||
}
|
||||
@ -157,7 +157,7 @@ Collection.prototype.update = function (models) {
|
||||
var error = model.validate();
|
||||
if (undefined !== error)
|
||||
{
|
||||
// @todo Better system inspired by Backbone.js.
|
||||
// TODO: Better system inspired by Backbone.js.
|
||||
throw error;
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ Collection.prototype.update = function (models) {
|
||||
//Collection.extend = require('extendable');
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Methods to override in implentations.
|
||||
// Methods to override in implementations.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@ -211,7 +211,7 @@ Collection.prototype._update = function (models) {
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Methods which may be overriden in implentations.
|
||||
// Methods which may be overriden in implementations.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,7 @@ function Memory(models)
|
||||
require('util').inherits(Memory, require('../collection'));
|
||||
|
||||
Memory.prototype._add = function (models, options) {
|
||||
// @todo Temporary mesure, implement “set()” instead.
|
||||
// TODO: Temporary mesure, implement “set()” instead.
|
||||
var replace = !!(options && options.replace);
|
||||
|
||||
for (var i = 0, n = models.length; i < n; ++i)
|
||||
|
@ -21,13 +21,13 @@ function create_redis_client(uri)
|
||||
// - prefix +':'+ id: hash containing the properties of a model;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
// @todo then-redis sends commands in order, we should use this
|
||||
// TODO: then-redis sends commands in order, we should use this
|
||||
// semantic to simplify the code.
|
||||
|
||||
// @todo Merge the options in the object to obtain extend-time
|
||||
// TODO: Merge the options in the object to obtain extend-time
|
||||
// configuration like Backbone.
|
||||
|
||||
// @todo Remote events.
|
||||
// TODO: Remote events.
|
||||
|
||||
function Redis(options, models)
|
||||
{
|
||||
@ -83,7 +83,7 @@ Redis.prototype._extract = function (ids) {
|
||||
};
|
||||
|
||||
Redis.prototype._add = function (models, options) {
|
||||
// @todo Temporary mesure, implement “set()” instead.
|
||||
// TODO: Temporary mesure, implement “set()” instead.
|
||||
var replace = !!(options && options.replace);
|
||||
|
||||
var redis = this.redis;
|
||||
@ -113,7 +113,7 @@ Redis.prototype._add = function (models, options) {
|
||||
throw 'cannot add existing model: '+ model.id;
|
||||
}
|
||||
|
||||
// @todo Remove existing fields.
|
||||
// TODO: Remove existing fields.
|
||||
|
||||
var params = [prefix +':'+ model.id];
|
||||
_.each(model, function (value, prop) {
|
||||
@ -211,7 +211,7 @@ Redis.prototype._remove = function (ids) {
|
||||
keys.push(prefix +':'+ ids[i]);
|
||||
}
|
||||
|
||||
// @todo Handle indexes.
|
||||
// TODO: Handle indexes.
|
||||
promises.push(
|
||||
redis.send('srem', [prefix +'_ids'].concat(ids)),
|
||||
redis.send('del', keys)
|
||||
@ -221,7 +221,7 @@ Redis.prototype._remove = function (ids) {
|
||||
};
|
||||
|
||||
Redis.prototype._update = function (models) {
|
||||
// @todo
|
||||
// TODO:
|
||||
return this._add(models, { 'replace': true });
|
||||
};
|
||||
|
||||
|
@ -31,14 +31,13 @@ $promisify = (fn) ->
|
||||
|
||||
deferred.promise
|
||||
|
||||
# Makes the fiber waits for a number of miliseconds.
|
||||
# Makes the fiber waits for a number of milliseconds.
|
||||
$sleep = (ms) ->
|
||||
fiber = $fiber.current
|
||||
setTimeout (-> fiber.run()), ms
|
||||
$fiber.yield()
|
||||
|
||||
# Makes an Node like asynchrouneous function synchrouneous (in a
|
||||
# fiber).
|
||||
# Makes an Node like asynchronous function synchronous (in a fiber).
|
||||
$synchronize = (fn, ctx) ->
|
||||
fn = ctx[fn] if $_.isString fn
|
||||
|
||||
|
@ -115,7 +115,7 @@ do $fiberize ->
|
||||
webServer = new $WebServer()
|
||||
webServer.listen options for options in $nconf.get 'http:listen'
|
||||
|
||||
# Waits for the web server to start listening to drop priviledges.
|
||||
# Waits for the web server to start listening to drop privileges.
|
||||
$waitEvent webServer, 'listening'
|
||||
try
|
||||
if (group = $nconf.get 'group')?
|
||||
@ -161,6 +161,6 @@ do $fiberize ->
|
||||
socket.on 'message', $fiberize (request) ->
|
||||
response = $handleJsonRpcCall api, session, request
|
||||
|
||||
# The socket may have closed beetween the request and the
|
||||
# The socket may have closed between the request and the
|
||||
# response.
|
||||
socket.send response if socket.readyState is socket.OPEN
|
||||
|
@ -93,7 +93,7 @@ Model.prototype.set = function (properties, value) {
|
||||
* Unsets properties.
|
||||
*/
|
||||
Model.prototype.unset = function (properties) {
|
||||
// @todo Events.
|
||||
// TODO: Events.
|
||||
this.properties = _.omit(this.properties, properties);
|
||||
};
|
||||
|
||||
|
@ -12,7 +12,7 @@ $xmlrpc = require 'xmlrpc'
|
||||
|
||||
#=====================================================================
|
||||
|
||||
# Note: All methods are synchroneous (using fibers).
|
||||
# Note: All methods are synchronous (using fibers).
|
||||
class $XAPI
|
||||
|
||||
constructor: ({@host, @username, @password}) ->
|
||||
@ -34,7 +34,7 @@ class $XAPI
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
|
||||
# Make `methodCall()` synchroneous.
|
||||
# Make `methodCall()` synchronous.
|
||||
@xmlrpc.methodCall = $synchronize 'methodCall', @xmlrpc
|
||||
|
||||
# Logs in.
|
||||
@ -57,14 +57,14 @@ class $XAPI
|
||||
|
||||
# Something went wrong.
|
||||
error = result.ErrorDescription or value
|
||||
catch error # Catpture the error if it was thrown.
|
||||
catch error # Captures the error if it was thrown.
|
||||
|
||||
# Gets the error code for transport errors and XAPI errors.
|
||||
code = error.code or error[0]
|
||||
|
||||
switch code
|
||||
|
||||
# XAPI sommetimes close the connection when the server is no
|
||||
# XAPI sometimes close the connection when the server is no
|
||||
# longer pool master (`event.next`), so we have to retry at
|
||||
# least once to know who is the new pool master.
|
||||
when 'ECONNRESET', \
|
||||
|
@ -9,7 +9,7 @@ $crypto = require 'crypto'
|
||||
# Low level tools.
|
||||
$_ = require 'underscore'
|
||||
|
||||
# Password hasing.
|
||||
# Password hashing.
|
||||
$hashy = require 'hashy'
|
||||
|
||||
# Redis.
|
||||
@ -161,7 +161,7 @@ class $XO extends $EventEmitter
|
||||
# XAPI connections.
|
||||
@xapis = {}
|
||||
|
||||
# This function asynchroneously connects to a server, retrieves
|
||||
# This function asynchronously connects to a server, retrieves
|
||||
# all its objects and monitors events.
|
||||
connect = $fiberize (server) =>
|
||||
# Identifier of the connection.
|
||||
@ -234,7 +234,7 @@ class $XO extends $EventEmitter
|
||||
remove: false
|
||||
}
|
||||
|
||||
# Finaly, monitors events.
|
||||
# Finally, monitors events.
|
||||
loop
|
||||
xapi.call 'event.register', ['*']
|
||||
|
||||
@ -267,8 +267,9 @@ class $XO extends $EventEmitter
|
||||
remove: false
|
||||
}
|
||||
catch error
|
||||
# The error rethrown unless it is `SESSION_NOT_REGISTERED`
|
||||
# in which case the session will be registered again.
|
||||
# The error is re-thrown unless it is
|
||||
# `SESSION_NOT_REGISTERED` in which case the session will be
|
||||
# registered again.
|
||||
throw error unless error[0] is 'SESSION_NOT_REGISTERED'
|
||||
|
||||
# Connects to existing servers.
|
||||
@ -278,7 +279,7 @@ class $XO extends $EventEmitter
|
||||
@servers.on 'add', (servers) ->
|
||||
connect server for server in @servers
|
||||
|
||||
# TODO: Automaticall disconnects from removed servers.
|
||||
# TODO: Automatically disconnects from removed servers.
|
||||
|
||||
#=====================================================================
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user