8000 GitHub - qdsang/node-ral: a rpc client for nodejs
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

qdsang/node-ral

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

63 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-ral

Build Status Coverage Status

Usage

Install

npm install node-ral

RAL init

var RAL = require('node-ral').RAL;

RAL.init({
    //path to config files
    confDir : __dirname + path.sep + './config',
    logger : {
        "log_path" : __dirname + path.sep + '../logs'
    },
    //specify the server's idc, ral will priority use backend with same idc
    currentIDC : 'tc'
});

config file

Every file in confDir will be loaded as config

// config/config.js
module.exports = {
    'SOME_SERVICE': {
        unpack: 'json',
        pack: 'form',
        method: 'POST'
        encoding: 'gbk',
        balance: 'random',
        protocol: 'http',
        retry: 2,
        timeout: 500,
        server: [
            { host: '127.0.0.1', port: 8080}
        ]
    }
};

Also support json config file

{
    "SOME_SERVICE": {
        "unpack": "json",
        "pack": "form",
        "method": "POST"
        "encoding": "gbk",
        "balance": "random",
        "protocol": "http",
        "server": [
            { "host": "127.0.0.1", "port": 8080}
        ]
    }
}

Start a request

var RAL = require('node-ral').RAL;

var request = RAL('SOME_SERVICE', {
    path: '/user/info'
    data: {
        'name': 'hefangshi',
        'city': 'Beijing',
        'gender': 'Male'
    }
});

request.on('data', function(data){
    data.status.should.be.eql(0);
});

more usage can be found in /test/ral.js

TODO

Future Feature

Internal Only

Complicate

  • Base
    • Config
    • Balance
    • Logger
    • Converter
    • Protocol
    • RAL
    • Filter
  • Ext
    • Balance
      • RandomBalance
      • RoundRobinBalance
    • Filter
      • ConnectFilter
      • HealthFilter
    • Converter
      • JSON
      • String
      • Form
      • QueryString
      • Raw
      • FormData
      • Protobuf
      • Msgpack
    • Protocol
      • HTTP
      • HTTPS
      • Socket
  • Issue
    • Form unpack support GBK when use form-urlencoded
    • Use Stream in Protocol
    • Use Stream in Converter

About

a rpc client for nodejs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0