MCPcopy Index your code
hub / github.com/smallnest/rpcx

github.com/smallnest/rpcx @v1.9.3 sqlite

repository ↗ · DeepWiki ↗ · release v1.9.3 ↗
1,048 symbols 2,998 edges 111 files 385 documented · 37%
README
  • stable branch: v1.7.x
  • development branch: master

Official site: http://rpcx.io

License GoDoc github actions Go Report Card coveralls QQ3群

Notice: etcd

since rpcx 1.7.6, some plugins have been moved to the independent project:

Announce

A tcpdump-like tool added: rpcxdump。 You can use it to debug communications between rpcx services and clients.

Cross-Languages

you can use other programming languages besides Go to access rpcx services.

  • rpcx-gateway: You can write clients in any programming languages to call rpcx services via rpcx-gateway
  • http invoke: you can use the same http requests to access rpcx gateway
  • Java Services/Clients: You can use rpcx-java to implement/access rpcx services via raw protocol.
  • rust rpcx: You can write rpcx services in rust by rpcx-rs

If you can write Go methods, you can also write rpc services. It is so easy to write rpc applications with rpcx.

Installation

install the basic features:

go get -v github.com/smallnest/rpcx/...

If you want to use quickcp registry, use those tags to go getgo build or go run. For example, if you want to use all features, you can:

go get -v -tags "quic kcp" github.com/smallnest/rpcx/...

tags: - quic: support quic transport - kcp: support kcp transport

Which companies are using rpcx?

Features

rpcx is a RPC framework like Alibaba Dubbo and Weibo Motan.

rpcx is created for targets: 1. Simple: easy to learn, easy to develop, easy to integrate and easy to deploy 2. Performance: high performance (>= grpc-go) 3. Cross-platform: support raw slice of bytes, JSON, Protobuf and MessagePack. Theoretically it can be used with java, php, python, c/c++, node.js, c# and other platforms 4. Service discovery and service governance: support zookeeper, etcd and consul.

It contains below features - Support raw Go functions. There's no need to define proto files. - Pluggable. Features can be extended such as service discovery, tracing. - Support TCP, HTTP, QUIC and KCP - Support multiple codecs such as JSON, Protobuf, MessagePack and raw bytes. - Service discovery. Support peer2peer, configured peers, zookeeper, etcd, consul and mDNS. - Fault tolerance:Failover, Failfast, Failtry. - Load banlancing:support Random, RoundRobin, Consistent hashing, Weighted, network quality and Geography. - Support Compression. - Support passing metadata. - Support Authorization. - Support heartbeat and one-way request. - Other features: metrics, log, timeout, alias, circuit breaker. - Support bidirectional communication. - Support access via HTTP so you can write clients in any programming languages. - Support API gateway. - Support backup request, forking and broadcast.

rpcx uses a binary protocol and platform-independent, which means you can develop services in other languages such as Java, python, nodejs, and you can use other prorgramming languages to invoke services developed in Go.

There is a UI manager: rpcx-ui.

Performance

Test results show rpcx has better performance than other rpc framework except standard rpc lib.

The benchmark code is at rpcx-benchmark.

Listen to others, but test by yourself.

Test Environment

  • CPU: Intel(R) Xeon(R) CPU E5-2630 v3 @ 2.40GHz, 32 cores
  • Memory: 32G
  • Go: 1.9.0
  • OS: CentOS 7 / 3.10.0-229.el7.x86_64

Use - protobuf - the client and the server on the same server - 581 bytes payload - 500/2000/5000 concurrent clients - mock processing time: 0ms, 10ms and 30ms

Test Result

mock 0ms process time

ThroughputsMean LatencyP99 Latency

mock 10ms process time

ThroughputsMean LatencyP99 Latency

mock 30ms process time

ThroughputsMean LatencyP99 Latency

Examples

You can find all examples at rpcxio/rpcx-examples.

The below is a simple example.

Server

    // define example.Arith
    ……

    s := server.NewServer()
    s.RegisterName("Arith", new(example.Arith), "")
    s.Serve("tcp", addr)

Client

    // prepare requests
    ……

    d, err := client.NewPeer2PeerDiscovery("tcp@"+addr, "")
    xclient := client.NewXClient("Arith", client.Failtry, client.RandomSelect, d, client.DefaultOption)
    defer xclient.Close()
    err = xclient.Call(context.Background(), "Mul", args, reply, nil)

Contributors

Contribute

see contributors.

Welcome to contribute: - submit issues or requirements - send PRs - write projects to use rpcx - write tutorials or articles to introduce rpcx

License

Apache License, Version 2.0

Extension points exported contracts — how you extend this code

Selector (Interface)
Selector defines selector that selects one service from candidates. [6 implementers]
client/selector.go
Codec (Interface)
Codec defines the interface that decode/encode payload. [7 implementers]
codec/codec.go
Reset (Interface)
Reset defines Reset method for pooled object. [6 implementers]
server/pool.go
PostConnAcceptPlugin (Interface)
PostConnAcceptPlugin represents connection accept plugin. if returns false, it means subsequent IPostConnAcceptPlugins s [7 …
server/plugin.go
ServiceDiscovery (Interface)
ServiceDiscovery defines ServiceDiscovery of zookeeper, etcd and consul [4 implementers]
client/discovery.go
PreCallPlugin (Interface)
PreCallPlugin is invoked before the client calls a server. [3 implementers]
client/plugin.go
Compressor (Interface)
Compressor defines a common compression interface. [3 implementers]
protocol/compressor.go
XClient (Interface)
XClient is an interface that used by client with service discovery and service governance. One XClient is used only for [1 …
client/xclient.go

Core symbols most depended-on inside this repo

Unlock
called by 83
share/context.go
Lock
called by 79
share/context.go
Errorf
called by 64
log/logger.go
Close
called by 49
client/xclient.go
Fatalf
called by 47
log/logger.go
Errorf
called by 34
log/logger.go
Get
called by 33
server/pool.go
Error
called by 30
log/logger.go

Shape

Method 610
Function 259
Struct 110
Interface 41
TypeAlias 15
FuncType 13

Languages

Go100%

Modules by API surface

server/plugin.go76 symbols
client/xclient.go55 symbols
protocol/testdata/benchmark.pb.go50 symbols
client/client.go47 symbols
client/plugin.go46 symbols
server/server.go43 symbols
protocol/message.go36 symbols
client/selector.go30 symbols
log/logger.go28 symbols
_testutils/arith_service.go28 symbols
_testutils/thrift_arith_service.go21 symbols
server/service.go20 symbols

Dependencies from manifests, versioned

github.com/akutz/memconnv0.1.0 · 1×
github.com/alitto/pondv1.9.2 · 1×
github.com/apache/thriftv0.21.0 · 1×
github.com/cenk/backoffv2.2.1+incompatible · 1×
github.com/cenkalti/backoffv2.2.1+incompatible · 1×
github.com/cespare/xxhash/v2v2.3.0 · 1×
github.com/dgryski/go-jumpv0.0.0-2021101820051 · 1×
github.com/dgryski/go-rendezvousv0.0.0-2020082301473 · 1×
github.com/edwingeng/doublejumpv1.0.1 · 1×
github.com/facebookgo/clockv0.0.0-2015041001091 · 1×
github.com/fatih/camelcasev1.0.0 · 1×

For agents

$ claude mcp add rpcx \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact