How to use memdb-logger - 10 common examples

To help you get started, we’ve selected a few memdb-logger examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rain1017 / memdb / test / lib / connection.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var _ = require('lodash');
var should = require('should');
var env = require('../env');
var memdb = require('../../lib');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('connection test', function(){
    beforeEach(env.flushdb);

    it('find/update/insert/remove/commit/rollback', function(cb){
        var conn = null;
        var User = null, News = null;
        var user1 = {_id : '1', name : 'rain', age : 30};
        var user2 = {_id : '2', name : 'tina', age : 24};
        var news1 = {_id : '1', text : 'hello'};

        return P.try(function(){
            return env.startCluster('s1');
        })
        .then(function(){
            return memdb.connect(env.config.shards.s1)
github rain1017 / memdb / test / lib / mdbgoose.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var util = require('util');
var should = require('should');
var env = require('../env');
var memdb = require('../../lib');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('mdbgoose test', function(){
    beforeEach(env.flushdb);

    it('mdbgoose', function(cb){
        var mdbgoose = memdb.goose;

        delete mdbgoose.connection.models.player;

        var Player = mdbgoose.model('player', new mdbgoose.Schema({
            _id : String,
            areaId : String,
            name : String,
            fullname : {first: String, second: String},
            items : [mdbgoose.SchemaTypes.Mixed],
            extra : mdbgoose.SchemaTypes.Mixed,
github rain1017 / memdb / test / app / document.js View on Github external
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var _ = require('lodash');
var should = require('should');
var assert = require('assert');
var Document = require('../../app/document'); // jshint ignore:line
var utils = require('../../app/utils');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('document test', function(){
    it('find', function(){
        var value = {k1 : 1, k2 : 1};
        var doc = new Document({_id : '1', doc : value});
        // Get all fields
        doc.find('c1').should.eql(value);
        // Get specified fields
        doc.find('c1', 'k1').should.eql({_id : '1', k1 : 1});
        doc.find('c1', {'k1' : true}).should.eql({_id : '1', k1 : 1});
        doc.find('c1', {'k1' : false}).should.eql({_id : '1', k2 : 1});
    });

    it('update', function(cb){
        var doc = new Document({_id : '1', doc : null, watchedFields : ['k1']});
github rain1017 / memdb / test / app / database.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var _ = require('lodash');
var should = require('should');
var env = require('../env');
var Database = require('../../app/database');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('database test', function(){
    beforeEach(env.flushdb);

    // it('find/update/insert/remove/commit/rollback', function(cb){
    //  //tested in ../lib/connection
    // });

    // it('index test', function(cb){
    //  //tested in ../lib/connection
    // });

    it('persistent / idle timeout', function(cb){
        var config = env.shardConfig('s1');
        config.persistentDelay = 50;
        config.idleTimeout = 500;
github rain1017 / memdb / test / app / shard.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var _ = require('lodash');
var should = require('should');
var env = require('../env');
var Shard = require('../../app/shard');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('shard test', function(){
    beforeEach(env.flushdb);

    it('load/unload/find/update/insert/remove/commit/rollback', function(cb){
        var shard = new Shard(env.shardConfig('s1'));
        var connId = 'c1', key = 'user$1', doc = {_id : '1', name : 'rain', age : 30};

        return P.try(function(){
            return shard.start();
        })
        .then(function(){
            // pre create collection for performance
            return shard.backend.conn.createCollectionAsync('user');
        })
        .then(function(){
github rain1017 / memdb / test / lib / autoconnection.js View on Github external
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var _ = require('lodash');
var should = require('should');
var memdb = require('../../lib');
var env = require('../env');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('autoconnection test', function(){
    beforeEach(env.flushdb);

    it('concurrent execute', function(cb){
        var shardId = Object.keys(env.config.shards)[0];
        var user1 = {_id : '1', name : 'rain', level : 0};
        var autoconn = null;

        return P.try(function(){
            return env.startCluster(shardId);
        })
        .then(function(){
            return memdb.autoConnect(env.config);
        })
        .then(function(ret){
github rain1017 / memdb / test / app / backendlocker.js View on Github external
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var should = require('should');
var logger = require('memdb-logger').getLogger('test', __filename);
var BackendLocker = require('../../app/backendlocker');
var env = require('../env');

describe('backendlocker test', function(){

    it('locker / heartbeat', function(cb){
        var docKey = 'player$p1', shardId = 's1';

        var locker = new BackendLocker({
                            host : env.config.locking.host,
                            port : env.config.locking.port,
                            db : env.config.locking.db,
                            shardId : shardId,
                            heartbeatTimeout : 2000,
                            heartbeatInterval : 1000,
                            });
github rain1017 / memdb / test / lib / backend.js View on Github external
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var should = require('should');
var memdb = require('../../lib');
var env = require('../env');
var logger = require('memdb-logger').getLogger('test', __filename);

describe('access backend test', function(){
    it('connect backend', function(cb){
        var db = null, errCount = 0;
        return P.try(function(){
            return memdb.connectBackend(env.config.backend);
        })
        .then(function(ret){
            db = ret;
            // find should success
            return db.collection('player').findOneAsync()
            .then(function(doc){
                logger.info('%j', doc);
            });
        })
        .then(function(){
github rain1017 / memdb / test / perf.js View on Github external
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var P = require('bluebird');
var _ = require('lodash');
var util = require('util');
var utils = require('../app/utils');
var should = require('should');
var env = require('./env');
var memdb = require('../lib');
var Database = require('../app/database');
var AutoConnection = require('../lib/autoconnection');
var logger = require('memdb-logger').getLogger('test', __filename);

describe.skip('performance test', function(){
    beforeEach(env.flushdb);
    after(env.flushdb);

    it('standard', function(cb){
        this.timeout(3600 * 1000);

        var runTest = function(opts){
            opts = opts || {};

            var shardCount = opts.shardCount || 1;
            var playerCount = opts.playerCount || 100;
            var areaCount = Math.floor(opts.areaCount || (playerCount / 10));
            var transOps = opts.transOps || 5;
            var useIndex = opts.useIndex || false;
github rain1017 / memdb / lib / protocol.js View on Github external
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.

'use strict';

var util = require('util');
var EventEmitter = require('events').EventEmitter;
var P = require('bluebird');
var logger = require('memdb-logger').getLogger('memdb-client', __filename);

var Protocol = function(opts){
    EventEmitter.call(this);

    opts = opts || {};

    this.socket = opts.socket;
    this.socket.setEncoding('utf8');

    this.remainLine = '';

    var self = this;
    this.socket.on('data', function(data){
        // message is json encoded and splited by '\n'
        var lines = data.split('\n');
        for(var i=0; i

memdb-logger

pomelo-logger ========

MIT
Latest version published 9 years ago

Package Health Score

36 / 100
Full package analysis

Popular memdb-logger functions

Similar packages