6 个版本 (重大更改)
| 0.6.0 | 2021 年 2 月 3 日 | 
|---|---|
| 0.5.0 | 2021 年 2 月 3 日 | 
| 0.4.0 | 2020 年 9 月 4 日 | 
| 0.3.0 | 2020 年 9 月 4 日 | 
| 0.1.0 | 2019 年 11 月 17 日 | 
#45 in #负载均衡
10KB
205 行
jsonrpc-proxy
状态
这个库已经有一段时间没有更新了,这里仅作存档之用。您可能可以考虑查看 https://github.com/AcalaNetwork/subway,它应该具有相同的目的,并且更新得更加及时。
概览
该代理具有可插拔的中间件架构。每个中间件都会接收每个 RPC 调用,并可以决定是终止它(返回响应)还是将其传递给下一个中间件。中间件还可以修改响应对象。
作为最后一个中间件,我们使用 Upstream 中间件,它负责调用目标节点。
包含在此存储库中的中间件
- 简单的缓存中间件
- 简单的权限中间件
- WebSocket 上游中间件
同样可插拔的是代理公开的 JSON-RPC 传输。目前支持
- TCP 服务器
- HTTP 服务器
- IPC 服务器
- WebSocket 服务器
想法
- 速率限制
- 故障转移
- 负载均衡
用法
rpc-proxy 0.1
Parity Technologies Ltd <admin@parity.io>
Generic RPC proxy, featuring caching and load balancing.
USAGE:
    rpc-proxy [OPTIONS]
FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information
OPTIONS:
        --cached-methods-path <cached-methods-path>
            A path to a JSON file containing a list of methods that should be
            cached. See examples for the file schema. [default: -]
        --http-cors <http-cors>
            Specify CORS header for HTTP JSON-RPC API responses.Special options:
            "all", "null", "none". [default: none]
        --http-cors-max-age <http-cors-max-age>
            Configures AccessControlMaxAge header value in milliseconds.Informs
            the client that the preflight request is not required for the
            specified time. Use 0 to disable. [default: 3600000]
        --http-hosts <http-hosts>
            List of allowed Host header values. This option willvalidate the
            Host header sent by the browser, it isadditional security against
            some attack vectors. Specialoptions: "all", "none". [default: none]
        --http-ip <http-ip>
            Configures HTTP server interface. [default: 127.0.0.1]
        --http-max-payload <http-max-payload>
            Maximal HTTP server payload in Megabytes. [default: 5]
        --http-port <http-port>
            Configures HTTP server listening port. [default: 9934]
        --http-rest-api <http-rest-api>
            Enables REST -> RPC converter for HTTP server. Allows you tocall RPC
            methods with `POST /<methodname>/<param1>/<param2>`.The "secure"
            option requires the `Content-Type: application/json`header to be
            sent with the request (even though the payload is ignored)to prevent
            accepting POST requests from any website (via form submission).The
            "unsecure" option does not require any `Content-Type`.Possible
            options: "unsecure", "secure", "disabled". [default: disabled]
        --http-threads <http-threads>
            Configures HTTP server threads. [default: 4]
        --ipc-path <ipc-path>
            Configures IPC server socket path. [default: ./jsonrpc.ipc]
        --ipc-request-separator <ipc-request-separator>
            Configures TCP server request separator (single byte). If "none" the
            parser will try to figure out requests boundaries. [default: none]
        --tcp-ip <tcp-ip>
            Configures TCP server interface. [default: 127.0.0.1]
        --tcp-port <tcp-port>
            Configures TCP server listening port. [default: 9955]
        --tcp-request-separator <tcp-request-separator>
            Configures TCP server request separator (single byte). If "none" the
            parser will try to figure out requests boundaries. Default is new
            line character. [default: 10]
        --upstream-ws <upstream-ws>
            Address of the parent WebSockets RPC server that we should connect
            to. [default: ws://127.0.0.1:9944]
        --websockets-hosts <websockets-hosts>
             List of allowed Host header values. This option will validate the
            Host header sent by the browser, it is additional security against
            some attack vectors. Special options: "all", "none". [default: none]
        --websockets-ip <websockets-ip>
            Configures WebSockets server interface. [default: 127.0.0.1]
        --websockets-max-connections <websockets-max-connections>
            Maximum number of allowed concurrent WebSockets JSON-RPC
            connections. [default: 100]
        --websockets-origins <websockets-origins>
             Specify Origin header values allowed to connect. Special options:
            "all", "none".  [default: none]
        --websockets-port <websockets-port>
            Configures WebSockets server listening port. [default: 9945]
lib.rs:
一组用于构建以太坊交易的原始组件。
依赖关系
~1–1.7MB
~36K SLoC