rpcxio / rpcx-gateway Goto Github PK
View Code? Open in Web Editor NEWhttp gateway for rpcx services. Clients in any programming languages can call them
License: Apache License 2.0
http gateway for rpcx services. Clients in any programming languages can call them
License: Apache License 2.0
add charset=utf-8 in response header
类似grpc-gateway,在定义method时指定http路径,请求时不需要通过header设置service/method,直接请求对应的URL path即可。这样感觉更方便些
rpc Echo(StringMessage) returns (StringMessage) {
option (google.api.http) = {
post: "/v1/example/echo"
body: "*"
};
}
请求同一个rpcx服务,第一下好的,第二下就会报错,一直循环
报错信息:
failed to dial server: dial tcp: address /rpc/xxxx: missing port in address
采用 etcd v3,单etcd节点,
后端rpcx服务提示:client has closed this connection
运行 cmd/gateway.go 后报错如下:
./gateway.go:56:10: undefined: client.NewZookeeperDiscoveryTemplate
./gateway.go:58:10: undefined: client.NewEtcdDiscoveryTemplate
./gateway.go:60:10: undefined: client.NewConsulDiscoveryTemplate
依赖
github.com/rpcxio/rpcx-etcd v0.0.0-20201229103411-8317fc934fbb
而rpcx-etcd 这个版本需要go.etcd.io/[email protected]版本,
然后使用了goproxy.io代理后查看etcd所有版本go list -m -json -versions go.etcd.io/etcd@latest,缺少3.4.14版本。
{
"Path": "go.etcd.io/etcd",
"Version": "v3.3.25+incompatible",
"Versions": [
"v0.1.0",
"v0.1.1",
"v0.1.2",
"v0.2.0-rc0",
"v0.2.0-rc1",
"v0.2.0-rc2",
"v0.2.0-rc3",
"v0.2.0-rc4",
"v0.2.0",
"v0.3.0",
"v0.4.0",
"v0.4.1",
"v0.4.2",
"v0.4.3",
"v0.4.4",
"v0.4.5",
"v0.4.6",
"v0.4.7",
"v0.4.8",
"v0.4.9",
"v0.5.0-alpha.0",
"v0.5.0-alpha.1",
"v0.5.0-alpha.2",
"v0.5.0-alpha.3",
"v0.5.0-alpha.4",
"v0.5.0-alpha.5",
"v2.0.0-rc.1+incompatible",
"v2.0.0+incompatible",
"v2.0.1+incompatible",
"v2.0.2+incompatible",
"v2.0.3+incompatible",
"v2.0.4+incompatible",
"v2.0.5+incompatible",
"v2.0.6+incompatible",
"v2.0.7+incompatible",
"v2.0.8+incompatible",
"v2.0.9+incompatible",
"v2.0.10+incompatible",
"v2.0.11+incompatible",
"v2.0.12+incompatible",
"v2.0.13+incompatible",
"v2.1.0-alpha.0+incompatible",
"v2.1.0-alpha.1+incompatible",
"v2.1.0-rc.0+incompatible",
"v2.1.0+incompatible",
"v2.1.1+incompatible",
"v2.1.2+incompatible",
"v2.1.3+incompatible",
"v2.2.0-alpha.0+incompatible",
"v2.2.0-alpha.1+incompatible",
"v2.2.0-rc.0+incompatible",
"v2.2.0+incompatible",
"v2.2.1+incompatible",
"v2.2.2+incompatible",
"v2.2.3+incompatible",
"v2.2.4+incompatible",
"v2.2.5+incompatible",
"v2.3.0-alpha.0+incompatible",
"v2.3.0-alpha.1+incompatible",
"v2.3.0+incompatible",
"v2.3.1+incompatible",
"v2.3.2+incompatible",
"v2.3.3+incompatible",
"v2.3.4+incompatible",
"v2.3.5+incompatible",
"v2.3.6+incompatible",
"v2.3.7+incompatible",
"v2.3.8+incompatible",
"v3.0.0-beta.0+incompatible",
"v3.0.0+incompatible",
"v3.0.1+incompatible",
"v3.0.2+incompatible",
"v3.0.3+incompatible",
"v3.0.4+incompatible",
"v3.0.5+incompatible",
"v3.0.6+incompatible",
"v3.0.7+incompatible",
"v3.0.8+incompatible",
"v3.0.9+incompatible",
"v3.0.10+incompatible",
"v3.0.11+incompatible",
"v3.0.12+incompatible",
"v3.0.13+incompatible",
"v3.0.14+incompatible",
"v3.0.15+incompatible",
"v3.0.16+incompatible",
"v3.0.17+incompatible",
"v3.1.0-alpha.0+incompatible",
"v3.1.0-alpha.1+incompatible",
"v3.1.0-rc.0+incompatible",
"v3.1.0-rc.1+incompatible",
"v3.1.0+incompatible",
"v3.1.1+incompatible",
"v3.1.2+incompatible",
"v3.1.3+incompatible",
"v3.1.4+incompatible",
"v3.1.5+incompatible",
"v3.1.6+incompatible",
"v3.1.7+incompatible",
"v3.1.8+incompatible",
"v3.1.9+incompatible",
"v3.1.10+incompatible",
"v3.1.11+incompatible",
"v3.1.12+incompatible",
"v3.1.13+incompatible",
"v3.1.14+incompatible",
"v3.1.15+incompatible",
"v3.1.16+incompatible",
"v3.1.17+incompatible",
"v3.1.18+incompatible",
"v3.1.19+incompatible",
"v3.1.20+incompatible",
"v3.2.0-rc.0+incompatible",
"v3.2.0-rc.1+incompatible",
"v3.2.0+incompatible",
"v3.2.1+incompatible",
"v3.2.2+incompatible",
"v3.2.3+incompatible",
"v3.2.4+incompatible",
"v3.2.5+incompatible",
"v3.2.6+incompatible",
"v3.2.7+incompatible",
"v3.2.8+incompatible",
"v3.2.9+incompatible",
"v3.2.10+incompatible",
"v3.2.11+incompatible",
"v3.2.12+incompatible",
"v3.2.13+incompatible",
"v3.2.14+incompatible",
"v3.2.15+incompatible",
"v3.2.16+incompatible",
"v3.2.17+incompatible",
"v3.2.18+incompatible",
"v3.2.19+incompatible",
"v3.2.20+incompatible",
"v3.2.21+incompatible",
"v3.2.22+incompatible",
"v3.2.23+incompatible",
"v3.2.24+incompatible",
"v3.2.25+incompatible",
"v3.2.26+incompatible",
"v3.2.27+incompatible",
"v3.2.28+incompatible",
"v3.2.29+incompatible",
"v3.2.30+incompatible",
"v3.2.31+incompatible",
"v3.3.0-rc.0+incompatible",
"v3.3.0-rc.1+incompatible",
"v3.3.0-rc.2+incompatible",
"v3.3.0-rc.3+incompatible",
"v3.3.0-rc.4+incompatible",
"v3.3.0+incompatible",
"v3.3.1+incompatible",
"v3.3.2+incompatible",
"v3.3.3+incompatible",
"v3.3.4+incompatible",
"v3.3.5+incompatible",
"v3.3.6+incompatible",
"v3.3.7+incompatible",
"v3.3.8+incompatible",
"v3.3.9+incompatible",
"v3.3.10+incompatible",
"v3.3.11+incompatible",
"v3.3.12+incompatible",
"v3.3.13+incompatible",
"v3.3.15+incompatible",
"v3.3.16+incompatible",
"v3.3.17+incompatible",
"v3.3.18+incompatible",
"v3.3.19+incompatible",
"v3.3.20+incompatible",
"v3.3.21+incompatible",
"v3.3.22+incompatible",
"v3.3.24+incompatible",
"v3.3.25+incompatible"
],
"Time": "2020-08-24T19:33:27Z",
"GoMod": "C:\GoPath\pkg\mod\cache\download\go.etcd.io\etcd\@v\v3.3.25+incompatible.mod"
}
Current rpcx supports peer2peer, multiplepeers, zookeeper, etcd, consul, mdns registries. Gateway needs to add a common tool to support those registries
cmd/gateway.go registry参数在不同注册方式上怎么写,能给一个例子吗?目前只看见一个peer2peer
rpcx-gateway是无状态应用,所以可以轻松做到扩展。但如果是有状态服务的请求,rpcx-gateway是如何支持的,还是目前未支持有状态服务请求?
比如认证 auth的key是__AUTH,写法是 k1=v1&k2=v2等
'X-RPCX-Meta': [
"__AUTH=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTA0MzI3MTYsImlzcyI6ImhqeC1zZXJ2aWNlcyJ9.0d6qHC0Q1DJr_H58tiHkH0a6wpM4fH8mfBdFI-A1zYY"
]
rpcx-gateway只能通过代码方式发送http请求?不能像grpc-gateway一样使用curl的方式发送请求?
Run go get -tags "xxx" github.com/rpcx-ecosystem/rpcx-gateway/cmd, and The following error appears
NewZookeeperDiscoveryTemplate is not found
gateway也没有办法将json转换为messsagePack编码,json的number没法准确的对应messagePack的Integer和Float
我用C实现了RPCX协议的简单通信,希望gateway能提供基于TCP的代理模式
geteway和agent只有客户端例子,服务端怎么写呢?我看server里面写的和一般的服务端没什么区别,服务端监听的是8872,但是http请求的是9981端口,这样也可以?
怎样启动geteway,能有个教程就好了,对于新手有点懵,后面看见了cmd下面的代码才知道怎么回事儿了
This repo is a http gateway, I want to know is there any recommended WebSocket/TCP gateway?
I have a client which connect to server with WebSocket. And on the server side, I want to spilt the complicated logic into several service with RPC. So I need an WebSocket gateway.
请问一下,如果用这个网关,是把http 请求转成什么协议(tcp, quic ...)与rpc server 进行通信呢?
followed in gateway.go
g.mu.Lock()
if g.xclients[servicePath] == nil {
g.xclients[servicePath] = client.NewXClient(servicePath, g.FailMode, g.SelectMode, g.serviceDiscovery.Clone(servicePath), g.Option)
}
xc = g.xclients[servicePath]
g.mu.Unlock()
cannot run g.mu.Unlock()
if rpcx-service is not registed in consul, because call panic
in consul_disconvery.go
you could add defer
before g.mu.Unlock()
.
var (
addr = flag.String("addr", ":9981", "http server address")
st = flag.String("st", "http1", "server type: http1 or h2c")
//registry = flag.String("registry", "peer2peer://127.0.0.1:8972", "registry address")
registry = flag.String("registry", "consul://localhost:8500", "registry address")
--------- i use consul ------
......
case "consul": //regAddr is localhost:8500
return client.NewConsulDiscovery(*basePath, "placeholder", []string{regAddr}, nil), nil
compli error:
2018/01/06 12:20:06 consul_discovery.go:59: INFO : cannot get services of from registry: rpcx/placeholder%!(EXTRA *errors.errorString=Key not found in store)
panic: Key not found in store
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.