clouds-controller
clouds模块(https://github.com/leizongmin/clouds )的可选控制器
Last updated 5 years ago by leizongmin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install clouds-controller 
SYNC missed versions from official npm registry.

clouds-controller

clouds模块(https://github.com/leizongmin/clouds )的可选控制器

安装

$ npm install clouds-controller --save

使用

1、配置clouds客户端

var clouds = require('clouds');
var cloudsController = require('clouds-controller');


var client = new clouds.Client({
  // 配置clouds-controller的connection
  connection: cloudsController.createConnection({
    port: 6480,
    host: '127.0.0.1'
  }),
  // 调用超时时间,如果服务器超过指定时间没有响应结果,则认为调用失败,单位:秒
  timeout: 2
});


var server = new clouds.Server({
  // 配置clouds-controller的connection
  connection: cloudsController.createConnection({
    port: 6480,
    host: '127.0.0.1'
  }),
  // 心跳周期,如果服务器端异常下线,超过指定时间将自动从服务器端删除,单位:秒
  heartbeat: 2
});

主要是在初始化客户端时传递一个connection参数来指定clouds-controller的连接,详细使用方法可参考clouds模块的文档。

2、启动clouds-controller服务器

可以编写以下代码来启动:

var cloudsController = require('clouds-controller');

var server = cloudsController.createServer();
server.listen(6480, '127.0.0.1');

也可以通过安装clouds-controller命令来启动:

$ npm install clouds-controller -g
$ clouds-controller -h 127.0.0.1 -p 6480

Coverage

$ ./run_coverage

91% coverage, 442 SLOC

Tests

$ ./run_test

License

The MIT License (MIT)

Copyright (c) 2015 Zongmin Lei <leizongmin@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Current Tags

  • 0.0.2                                ...           latest (5 years ago)

3 Versions

  • 0.0.2                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
  • 0.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 4
Last Month 4
Dependencies (7)
Dev Dependencies (4)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |