This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var assert = require('assert'), | |
director = require('director'), | |
EventEmitter = require('events').EventEmitter, | |
ns,// = require('continuation-local-storage').createNamespace('testing'), | |
express = require('express'), | |
app = express(), | |
domain = require('domain'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In this example we'd like to have a factory that works per request and allows to keep track of created Models | |
// The singleton will however apply to all requests and thus keep growing | |
// For that reason we supply it with a reset function. | |
// This works fine until between receiving a request and sending a response there is no asynchronous code execution | |
// Once multiple requests come in in very short intervals, the asynchronous execution will lead to requests cross-polluting | |
// the singleton class | |
// factory.js | |
// | |
// Should be per-request so we can keep track |