| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- {
- "name": "quick-pomelo",
- "description": "Scalable, Transactional and Reliable Game Server Framework based on Pomelo and MemDB",
- "version": "0.2.4",
- "author": {
- "name": "rain1017"
- },
- "private": false,
- "homepage": "https://github.com/rain1017/quick-pomelo",
- "repository": {
- "type": "git",
- "url": "git+https://github.com/rain1017/quick-pomelo.git"
- },
- "bugs": {
- "url": "https://github.com/rain1017/quick-pomelo/issues"
- },
- "keywords": [
- "quick",
- "pomelo",
- "memdb",
- "game",
- "framework",
- "transaction"
- ],
- "engines": {
- "node": ">=0.12.5"
- },
- "scripts": {
- "start": "grunt",
- "test": "grunt test",
- "postinstall": ""
- },
- "dependencies": {
- "memdb-client": "~0.5.7",
- "lodash": "~3.10.1",
- "underscore": "~1.8.2",
- "grunt-cli": "~0.1.13",
- "require-directory": "~2.1.1",
- "ws": "~0.8.0",
- "pomelo-protocol": "~0.1.6",
- "pomelo-protobuf": "~0.4.0"
- },
- "devDependencies": {
- "should": "~4.5.0",
- "sinon": "~1.12.2",
- "grunt-env": "~0.4.2",
- "grunt-contrib-jshint": "~0.10.0",
- "grunt-contrib-clean": "~0.6.0",
- "grunt-mocha-test": "~0.12.6",
- "load-grunt-tasks": "~2.0.0",
- "blanket": "~1.1.6",
- "redis": "~0.12.1",
- "mongodb": "~2.0.39"
- },
- "contributors": [
- {
- "name": "rain1017",
- "email": "rain1017@gmail.com"
- }
- ],
- "gitHead": "3d2c83d81ab190e99a3ab8f64385aa29f44c5383",
- "readme": "# quick-pomelo \r\n\r\n[](https://travis-ci.org/rain1017/quick-pomelo)\r\n[](https://david-dm.org/rain1017/quick-pomelo)\r\n\r\n__Scalable, Transactional and Reliable Game Server Framework based on Pomelo and MemDB__\r\n\r\n### Performance and Scalable\r\n* Fast in-memory data access.\r\n* Distributed architecture, system capacity is horizontally scalable. Performance can be linearly increased by simply add more servers.\r\n\r\n### Distributed ACID Transaction\r\n* [ACID](https://en.wikipedia.org/wiki/ACID)(Stands for Atomicity, Consistency, Isolation, Durability) transaction support on distributed environment.\r\n* Data atomicity and consistency guarantee, never leave dirty data in memory.\r\n* Concurrency and locking control, which make it very easy to write concurrency code. High performance on concurrent system.\r\n\r\n### High Availability\r\n* Each server is backed by one or more replica, no single point of failure.\r\n\r\n### MVC Architecture\r\n* Simple and clear Module-Controller architecture.\r\n* Use [Mongoose](http://mongoosejs.com) to define data models.\r\n\r\n### ES6 Promise Supported\r\n* Promise A+ compatible\r\n* Support ES6 generators (yield)\r\n\r\n### Powerful Built-in Modules\r\n* Very powerful built-in modules, like push module. You can build a full featured push/chat service with almost zero code.\r\n\r\n## Links\r\n\r\n* Home Page: [http://quickpomelo.com](http://quickpomelo.com)\r\n* Github: [https://github.com/rain1017/quick-pomelo](https://github.com/rain1017/quck-pomelo)\r\n* Wiki: [https://github.com/rain1017/quick-pomelo/wiki](https://github.com/rain1017/quick-pomelo/wiki)\r\n* Demo Game: [https://github.com/rain1017/quick-pomelo-demo](https://github.com/rain1017/quick-pomelo-demo)\r\n* Email: [rain1017@gmail.com](mailto:rain1017@gmail.com)\r\n* QQ: 9040044\r\n* QQ discussion group: 292495320\r\n\r\n## Quick Start\r\n\r\n### Prerequisites\r\n\r\n#### [Pomelo](https://github.com/NetEase/pomelo)\r\n\r\nQuick-pomelo is based on pomelo, have a draft idea of pomelo framework is required.\r\n\r\n#### [MemDB](https://github.com/rain1017/memdb)\r\n\r\nQuick-pomelo use memdb for underlaying data storage, so understanding memdb is required.\r\n\r\n### Install dependencies\r\n\r\n* Install [Node.js](https://nodejs.org/download)\r\n* Install [Redis](http://redis.io/download) (required for memdb)\r\n* Install [MongoDB](https://www.mongodb.org/downloads) (required for memdb)\r\n* Install [MemDB](https://github.com/rain1017/memdb) globally\r\n```\r\nsudo npm install -g memdb-server\r\n```\r\n* Install pomelo globally\r\n```\r\nsudo npm install -g rain1017/pomelo\r\n```\r\n\r\n### Start with template\r\n\r\nFirst copy the template to your working directory. The template contains most common skeletons for a quick-pomelo game server.\r\n\r\n\r\n### Define models\r\n\r\nDefine data models in app/models directory\r\n\r\n```js\r\n// app/models/player.js\r\nmodule.exports = function(app){\r\n var mdbgoose = app.memdb.goose;\r\n\r\n var PlayerSchema = new mdbgoose.Schema({\r\n _id : {type : String},\r\n areaId : {type : String},\r\n teamId : {type : String},\r\n connectorId : {type : String},\r\n name : {type : String},\r\n }, {collection : 'players'});\r\n\r\n mdbgoose.model('Player', PlayerSchema);\r\n};\r\n```\r\n\r\n### Write controllers \r\n\r\nWrite controllers in app/controllers directory\r\n\r\n```js\r\n// app/controllers/player.js\r\nvar Controller = function(app){\r\n this.app = app;\r\n};\r\n\r\nvar proto = Controller.prototype;\r\n\r\nproto.createPlayerAsync = function(opts){\r\n // Get model by this.app.models.[model]\r\n var player = new this.app.models.Player(opts);\r\n yield player.saveAsync();\r\n};\r\n\r\nproto.removePlayerAsync = function(playerId){\r\n var player = yield this.app.models.Player.findAsync(playerId);\r\n if(!player){\r\n throw new Error('player not exist');\r\n }\r\n yield player.removeAsync();\r\n};\r\n\r\nmodule.exports = function(app){\r\n return new Controller(app);\r\n};\r\n```\r\n\r\n### Define routes\r\n\r\nFor each type of server, write a route in app/routes directory.\r\n\r\n```js\r\n// app/routes/player.js\r\nmodule.exports = {\r\n // Routing in handler\r\n handler : function(session, method, msg){\r\n // Return a string routing key\r\n // Same routing key always route to the same backend server.\r\n return session.uid || msg.playerId;\r\n },\r\n // Routing in remote\r\n remote : function(routeParam, method, args){\r\n return routeParam;\r\n }\r\n};\r\n```\r\n\r\n### Write server handlers\r\n\r\nWrite server handlers in app/servers/[server]/handler\r\n\r\n```js\r\n// app/servers/player/playerHandler.js\r\nvar Handler = function(app){\r\n this.app = app;\r\n};\r\n\r\nHandler.prototype.createPlayer = function(msg, session, next){\r\n // Get controller by this.app.controllers.[controler]\r\n return this.app.controllers.player.createPlayerAsync(msg.opts)\r\n .nodeify(next); \r\n};\r\n\r\nmodule.exports = function(app){\r\n return new Handler(app);\r\n};\r\n```\r\n\r\n### Start server\r\n\r\nBefore start\r\n* Make sure Redis and MongoDB has started.\r\n* Create a symbol link to `[PROJECT_ROOT]/config/memdb.conf.js` in `~/.memdb/`\r\n```\r\nmkdir ~/.memdb\r\nln -s [PROJECT_ROOT]/config/memdb.conf.js ~/.memdb/memdb.conf.js\r\n```\r\n* Start memdb cluster\r\n```\r\nmemdbcluster start\r\n```\r\n\r\nStart server\r\n```\r\npomelo start --harmony (--harmony is required on node < 0.4.0)\r\n```\r\n\r\n### Well done! Congratulations!\r\n\r\n\r\n## Quick's Philosophy\r\n\r\nA typical realtime game server framework is stateful for the sake of performance, all states is kept in server local memory. However, this approach has significant drawbacks:\r\n\r\n- Any exceptions (may be caused by bugs or unexpected client input) may result in non-consistent state (half-modified dirty data), which is very difficult to recover\r\n- Concurrency control is very difficult to implement\r\n- We must remember which server the data is located, and use rpc to get data, which is error prone.\r\n- In memory data will be lost on server failure, it's very difficult to support HA\r\n\r\nThanks to [MemDB](http://memdb.org), quick pomelo un-invent the stateful approach and use a web server like 'MVC' based architecture. All servers become stateless and all states is stored in memdb. You can now get all benefits from a typical stateless web server, without losing performance and scalability of in memory stateful server.\r\n\r\n\r\n## License\r\n\r\nCopyright 2015 rain1017.\r\n\r\nLicensed under the Apache License, Version 2.0 (the \"License\");\r\nyou may not use this file except in compliance with the License.\r\nYou may obtain a copy of the License at\r\n\r\n http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nUnless required by applicable law or agreed to in writing, software\r\ndistributed under the License is distributed on an \"AS IS\" BASIS,\r\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r\nimplied. See the License for the specific language governing\r\npermissions and limitations under the License. See the AUTHORS file\r\nfor names of contributors.\r\n",
- "readmeFilename": "README.md",
- "_id": "quick-pomelo@0.2.4",
- "_shasum": "0824910de849ba4bc8fbe971a240bec7c4b47c11",
- "_from": "memdb/quick-pomelo",
- "_resolved": "git://github.com/memdb/quick-pomelo.git#3d2c83d81ab190e99a3ab8f64385aa29f44c5383"
- }
|