apache / dubbo-go Goto Github PK
View Code? Open in Web Editor NEWGo Implementation For Apache Dubbo .
Home Page: https://dubbo.apache.org/
License: Apache License 2.0
Go Implementation For Apache Dubbo .
Home Page: https://dubbo.apache.org/
License: Apache License 2.0
What would you like to be added:
在dubbo协议下,go-client能通过传入配置参数的形式实例化一个dubbo客户端。
Why is this needed:
当go-client调用dubbo接口时,必须代码实现一个javabean的描述。这个使业务端如果要动态调用十分不方便。
比如服务端新增了一个接口,客户单必须更改代码,不能通过更改配置实现。
比如go服务要做一个网关形式的服务,无法完成一些透传接口的工作
比如接口过多,go客户端将会需要很多代码描述。
Go for Apache Dubbo can be changed to dubbo-go now~
The attachments will missing when decode with unexported field of struct:
https://github.com/dubbo/go-for-apache-dubbo/blob/31e1a220cfd8d38ca9bbdff043913a803ac90ac7/protocol/dubbo/readwriter.go#L121
通过proxyFactory动态代理机制会返回客户端调用服务的invoker对象,开发者在使用时只需要正常调用接口方法。
golang没有动态代理机制,需要考虑一种方式来做到最小化调用。
No | Task | owner | Status |
---|---|---|---|
1 | cluster strategy: Failfast/Failsafe/Failback | @xujianhai666 | done |
2 | loadbalance: RoundRobin/LeastActive | 诣极 | done |
3 | filter :AccessLogFilter | @flycash | done |
4 | routing rule | @aliiohs | doing |
5 | default monitor(prometheus) | 晓冬 | doing |
6 | trace(jeager impl) | 晓冬 | |
7 | asynchronous call | @zouyx | done |
8 | callback parameter | ||
9 | delay pubilsh | deprecated | |
10 | connections & concurrency control | ||
11 | lazy connection | @CodingSinger | |
12 | sticky connection | @CodingSinger | |
13 | Token Authorization | @xujianhai666 | done |
14 | Service-Downgrade | @YGrylls | done |
15 | graceful exit | @flycash | done |
16 | user guide outline | ||
17 | generic invoke | @pantianying | done |
18 | TPS limit | @flycash | done |
19 | loadbalance: ConsistentHash | @imxyb | |
20 | support java generics | ||
21 | appollo config center | @xujianhai666 | done |
22 | http restful | @yiduwangkai | |
23 | thrift supportl | @aliiohs | |
24 | etcd/consul config center impl | @xujianhai666 | |
25 | nacos config center impl | @amudong | done |
26 | setLoggerLevel function | @fangyincheng | doing |
27 | k8s as registry | @yiduwangkai | doing |
28 | grpc | @xujianhai666 | doing |
29 | protocol buffer | @skyitachi | doing |
30 | Adapt to Dubbo admin | ||
31 | generic implement | @Patrick0308 | done |
What happened:
Maven build failure on Java 11.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.257 s
[INFO] Finished at: 2019-06-06T14:56:32+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project user-info-server: Compilation failure: Compilation failure:
[ERROR] Source option 5 is no longer supported. Use 6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
What you expected to happen:
Build pass
How to reproduce it (as minimally and precisely as possible):
cd example/dubbo/java-server and run sh build.sh
Anything else we need to know?:
diff --git a/examples/dubbo/java-server/pom.xml b/examples/dubbo/java-server/pom.xml
index 9751578..da9c8b8 100644
--- a/examples/dubbo/java-server/pom.xml
+++ b/examples/dubbo/java-server/pom.xml
@@ -11,9 +11,12 @@
<description>The demo provider module of dubbo project</description>
<properties>
<skip_maven_deploy>false</skip_maven_deploy>
-
<dubbo-version>2.6.5</dubbo-version>
<dubbo-jsonrpc-version>1.0.1</dubbo-jsonrpc-version>
+ <maven_compiler_version>3.6.0</maven_compiler_version>
+ <java_source_version>1.6</java_source_version>
+ <java_target_version>1.6</java_target_version>
+ <file_encoding>UTF-8</file_encoding>
</properties>
<dependencyManagement>
@@ -172,6 +175,19 @@
</execution>
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>${maven_compiler_version}</version>
+ <configuration>
+ <compilerArgument>-proc:none</compilerArgument>
+ <fork>true</fork>
+ <source>${java_source_version}</source>
+ <target>${java_target_version}</target>
+ <encoding>${file_encoding}</encoding>
+ </configuration>
+ </plugin>
</plugins>
</build>
java与go接入问题:
现在我们与go对接,有一个问题,java的序列化go不能用,如果接入dubbo-go客户端,这个问题还要考虑么
我们现在用的是2.6.2的默认的序列化
dubbo://,hessian2
谢谢
What happened:
I use go client to call go server. Why I have to implement the pojo method named "JavaClassName"?
What you expected to happen:
Rename name .Or I do not need to register pojo when go client calling go server.
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
jsonrpc 2.0 server feature list:
service registration based on zookeeper;
using jsonrpc 2.0 protocol;
using http transport;
what time can be support Hessian Codec
I want use golang to call java Provider . but defualt Codec is Hessian not support .
当在服务端启动过程中,多次尝试启停zookeeper,一般大于3次后。下一次连接上zk,进行服务的注册操作,zk会返回ErrNodeExists错误。而程序zk_client.go RegisterTemp方法中忽略了该错误,认为服务已经注册,导致zk服务注册失败。
java registry unregister部分的源码,unregister这个的用途是:
1.provider在启动时也会启动registry的监听,当发现registry上注册的service内容跟本地刚启动时注册的service不一致时,就会刷新registry。
2.qos,允许运维人员对服务进行动态上下限。http://dubbo.apache.org/zh-cn/blog/introduction-to-dubbo-qos.html
1和2需求,暂时非紧急需求,先记个issue后面再完善。
When compiling the source code, remind the user to be careful with the architecture.
cd dubbo/go-client
#linux, mac windows represent the os
#release, dev and test represent the environment
sh ./assembly/linux/release.sh
For example:
sh ./asssembly/$ARCH/$ENV.sh
where $ARCH = [linux | mac | windows] and $ENV = [ release | dev | test]
Example: sh ./assembly/linux/release.sh
What happened:
当多个dubbo provider的场景下,若有某一个网络不可达,同时客户端进行尝试连接,返回
net.DialTimeout(addr xxx:, timeout:3e+09) = error:dial tcp xxx: i/o timeout,并且不会进行自动的轮询切换
What you expected to happen:
当多个dubbo provider的场景下,consumer发起请求时,若有部分provider不可达(无论是网络原因还是provider自身的原因),consumer应自动切换,并尝试连接别的provider
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
dubbo-go/examples/dubbo/go-server/app/server.go
Lines 69 to 90 in 4f7ef9d
What would you like to be added:
The code above may be placed in dubbo-go's code better than in user's code.
Why is this needed:
Does code above mean graceful exit? If this code is used frequently, we can move it to the dubbo-go's code so that users need not write it every time.
What happened:
当java端的Date是null,go端decode将会报错,如果使用*time.Time可ui接收null,但是将无法接收正常Date
What you expected to happen:
抛出的异常:
ERROR [email protected]/session.go:558 [session.handlePackage] error:decObject illegal object type tag:74 github.com/dubbogo/hessian2.(*Decoder).decObject
How to reproduce it (as minimally and precisely as possible):
go 作为 client 端,java作为server端,使用dubbogo框架进行调用
Anything else we need to know?:
What happened:
go get dubbo-go 1.0.0 有源码使用了旧包地址不能正常依赖
go get -u github.com/apache/dubbo-go
go: github.com/apache/[email protected]: parsing go.mod: unexpected module path "github.com/dubbo/go-for-apache-dubbo"
go get: error loading module requirements
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
like java GenericService
望支持
而这个timeout的来源其实是server端的Registry_Config配置,在这个配置中,这个单位是秒,并且默认是5。而在SetServiceReadDeadLine中其实默认单位是ms。
这样会造成client端在等待server端返回结果的conn中,等5ms就会超时。造成i/o timeout的bug。
待更新中...
What happened:
OpenJDK 64-Bit Server VM warning: Ignoring option PermSize; support was removed in 8.0
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Unrecognized VM option 'UseCMSCompactAtFullCollection'
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
What you expected to happen:
Server can start
How to reproduce it (as minimally and precisely as possible):
cd dubbo/java-server/target
tar -zxvf user-info-server-0.2.0-assembly.tar.gz
cd ./user-info-server-0.2.0
sh ./bin/server.sh start
Anything else we need to know?:
The option UseCMSCompactAtFullCollection
is no longer supported in Java 11. It is better to remove it.
What happened:
when set p2p module without registry , provider side will not be connected.
What you expected to happen:
consumer can invoke the service in provider by p2p.
How to reproduce it (as minimally and precisely as possible):
consumer & provider without registry configuration and consumer set "url" as provider's address.
Anything else we need to know?:
What would you like to be added:
1.go-client can not parse POJO in right way when java-server provide "Byte" as return
panic: Failed to invoke the method getTuple in the service com.*******.TupleProvider. Tried 3 times of the providers [dubbo://:@192.168.97.78:13675/com.*******.TupleProvider?group=&version= dubbo://:@192.168.97.78:13675/com.*******.TupleProvider?group=&version= dubbo://:@192.168.97.78:13675/com.*******.TupleProvider?group=&version=] (3/1)from the registry zookeeper://:@192.168.11.29:2181?group=®istry=zookeeper®istry.role=0®istry.timeout=3s on the consumer 192.168.97.78 using the dubbo version 2.6.0. Last error is unknown struct member type: int8.
2.go-client can not invoke nonparameter method provides by java-server
panic: runtime error: index out of range
public class Tuple implements Serializable {
private static final long serialVersionUID = -1L;
Integer Integer;
Byte Byte;
Short Short;
Long Long;
int i;
byte b;
short s;
long l;
}
public interface TupleProvider {
Tuple getTuple(Integer i);
Tuple getTheTuple();
}
@Component
public class TupleProviderImpl implements TupleProvider {
@Override
public Tuple getTuple(Integer i) {
return getTheTuple();
}
@Override
public Tuple getTheTuple() {
Tuple result = new Tuple();
result.setB((byte) 1);
result.setByte(Byte.valueOf("1"));
result.setI(1);
result.setInteger(Integer.valueOf("1"));
result.setL(1L);
result.setLong(Long.valueOf("1"));
result.setS((short) 1);
result.setShort(Short.valueOf("1"));
return result;
}
}
type Tuple struct {
Byte int8
Short int16
Integer int32
Long int64
B int8
S int16
I int32
L int64
}
func (t Tuple) JavaClassName() string {
return "com.***.Tuple"
}
type TupleProvider struct {
GetTuple func(i int32) (tuple *Tuple, err error) `dubbo:"getTuple"`
GetTheTuple func() (tuple *Tuple, err error) `dubbo:"getTheTuple"`
}
func (provider *TupleProvider) Service() string {
return "com.***.TupleProvider"
}
func (provider *TupleProvider) Version() string {
return ""
}
go hessian client/server feature list:
service registration based on zookeeper;
using hessian protocol;
using tcp transport;
What would you like to be added:
add failfastCluster
Why is this needed:
be consistent with java version
go-server启动service后,启动go-client。但是client报错:
panic: Failed to invoke the method GetUser in the service
(2/1)from the registry zookeeper://:@127.0.0.1:2181?group=®istry=zookeeper®istry.role=0®istry.timeout=3s on the consumer 192.168.99.1 using the dubbo version 2.5.3. Last error is can not find go type name in registry.
在zookeeper里有这个service:
[zk: localhost:2181(CONNECTED) 76] ls /dubbo/com.lagou.chenlei.demo.main.UserService/providers
[dubbo://10.71.8.99:12345/com.xxx.demo.main.UserService?anyhost=true&app.version=1.0&application=BDTService&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.5.3&environment=dev&group=&interface=com.xxx.demo.main.UserService&ip=192.168.99.1&loadbalance=random&methods.GetUser.loadbalance=&methods.GetUser.retries=0&methods.GetUser.weight=0&module=dubbogo+user-info+server&name=BDTService&organization=ikurento.com&owner=ZX&pid=59371&retries=0&side=provider×tamp=1558520537&version=&warmup=100]
func consumerInit(confConFile string) error {
if confConFile == "" {
return perrors.Errorf("application configure(consumer) file name is nil")
}
if path.Ext(confConFile) != ".yml" {
return perrors.Errorf("application configure file name{%v} suffix must be .yml", confConFile)
}
// when configCenter is apollo,configfile is remote config,can't read config.So hope provider read config through http.
confFileStream, err := ioutil.ReadFile(confConFile)
if err != nil {
return perrors.Errorf("ioutil.ReadFile(file:%s) = error:%v", confConFile, perrors.WithStack(err))
}
consumerConfig = &ConsumerConfig{}
err = yaml.Unmarshal(confFileStream, consumerConfig)
if err != nil {
return perrors.Errorf("yaml.Unmarshal() = error:%v", perrors.WithStack(err))
}
xxx
}
我们的服务运行在docker里,配置中心是携程的apollo。配置内容在配置中心上,通过配置中心来区分环境的。这里初始化直接读取本地的文件,实际上用不了。建议能够初始化时读取远程配置中心的配置,例如:apollo,etcd。
每个注册中心url都会在java中生成一个registry对象(即使是同一种注册中心类型如zookeeper,dubbo-java也会认为是多注册中心的情况)。所以java invoker的调用链为: RegistryAwareClusterInvoker(StaticDirectory) -> FailoverClusterInvoker(RegistryDirectory, will execute route) -> Invoker,需要先选取注册中心获取对应的缓存url list再去调用。
go版本目前未实现多种类注册中心,而对于同一种注册中心如zookeeper,在zk-client层就已经处理掉了,注册中心面向dubbo只有一个client实例。
How to quick start go-for-apache-dubbo.
What would you like to be added:
Why is this needed:
be consistent with javaimpl
My code is as follows
The problem is that exception java catched is not contain the go error message which should be ‘invalid params: uid, name, cert could not be empty’.
In fact, java-client always catch as follows:
Failed to invoke the method Init in the service com.xxx.service.go.base.certify.api.CertifyService. Tried 1 times of the providers [10.71.8.70:20001] (1/1) from the registry 10.71.8.70:2181 on the consumer 10.71.8.70 using the dubbo version 2.6.3. Last error is: Failed to invoke remote method: Init, provider: dubbo://10.71.8.70:20001/com.xxx.service.go.base.certify.api.CertifyService?anyhost=true&app.version=1.0&application=consumer-of-certify-app&category=providers&check=false&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&group=&interface=com.xxx.service.go.base.certify.api.CertifyService&ip=192.168.99.1&loadbalance=random&methods=Init&methods.Init.loadbalance=random&methods.Init.retries=3&methods.Init.weight=0&module=dubbogo+certify+server&name=CertifyService&organization=test.com&owner=raychen&pid=71023®ister.ip=10.71.8.70&remote.timestamp=1559621785&retries=0&service.filter=echo&side=consumer×tamp=1559622450690&version=&warmup=100, cause: 0
What happened:
There are these problems, when high concurrency and continuous stress testing:
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
github.com/dubbo/go-for-apache-dubbo/dubbo/client.go:237:21: undefined: hessian.Heartbeat
钉钉群号: 23331795
such as gopkg, govendor ...
项目对接时将bigdecimal改为string成功接收(证明不是连接问题)
改回bigdecimal后使用golang中的float64测试报错
然后再此时下方包中的Decimal,已经不能接收BigDecimal类型
import "github.com/shopspring/decimal"
尝试使用golang中的big类型同样失败
BigDecimal在Java中是常用的精确计算包装类,实际业务不可能改为浮点类型,所以该问题依旧是需要解决的问题
service provider improvement todo list:
func (p *Provider) GetUser(userID int64) (*User, error) {
...
return nil, nil
}
func (p *Provider) SetUserInfo(userInfo *User) error {
...
return nil
}
func (p *Provider) TakeUser() (*User, error) {
...
return &User{}
}
conMap, _ := config.Load()
res, err := conMap["com.ikurento.user.UserProvider"].GetRPCService("com.ikurento.user.UserProvider").(*UserProvider).Echo(context.TODO(), "OK")
if err != nil {
panic(err)
}
to
providerInstance, _ := config.Build()
res, err := providerInstance.GetRPCService("com.ikurento.user.UserProvider").(*UserProvider).Echo(context.TODO(), "OK")
if err != nil {
panic(err)
}
zk_client.go line248行,当zookeeper在server或者client运行时关掉,z.conn会为nil,则zk重连不会生效。
go-for-apache-dubbo hessian2 doesn't support generics yet,like Response<T>
。
com.ikurento.user.Response<T>
Responst<Integer> com.ikurento.user.UserProvider.sum(int a, int b)
type Response struct {
OK int32
ERR int32
Status int32
Err string
// How do I define this field
Data interface{}
}
func (Response) JavaClassName() string {
return "com.ikurento.user.Response"
}
func (r Response) String() string {
return fmt.Sprintf(
"Response{OK:%d, ERR:%d, Status:%d, Err:%s, Data:%s}",
r.OK, r.ERR,r.Status,r.Err,r.Data,
)
}
hessian.RegisterPOJO(&Response{})
response := &Response{}
err := conMap["com.ikurento.user.UserProvider"].GetRPCService().(*UserProvider).Sum(context.TODO(), []interface{}{1, 2}, response)
如题,实际测试后发现在server运行过程中,将zookeeper停掉后再启动,server因为这段逻辑的存在,会将原来的service如com.ikurento.user.UserProvider重新注册为com.ikurento.user.UserProvider1
Consider one of following implementation, or all:
add struct field named method name and DubboName suffix
type UserProvider struct {
GetUserDubboName struct{} `dubbo:"getUser"`
user map[string]User
}
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error {
...
}
func (u *UserProvider) Service() string {
return "com.my.UserProvider"
}
func (u *UserProvider) Version() string {
return ""
}
add struct
MethodAlias
Method returnmap[string]string
(init needed)
type UserProvider struct {
user map[string]User
}
func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error {
...
}
func (u *UserProvider) Service() string {
return "com.my.UserProvider"
}
func (u *UserProvider) Version() string {
return ""
}
func (u UserProvider) MethodAlias() map[string]string {
return map[string]string{"GetUser":"getUser"}
}
Welcome to use dubbo-go. To know who is using it, pls append your org info as follow,
欢迎使用dubbogo,首先感谢你的使用,其次您可以参考下面的样例来提供您的信息以收集下使用场景:
* 组织:阿里巴巴(Required)
* 地点:**杭州(Required)
* 联系方式:[email protected](Optional)
* 场景:阿里内部服务化改造(Required)
* 注册中心: zookeeper(Optional)
* 版本: 1.5.5(Optional)
* 公司图标:(Optional)
再次感谢你的参与!!!
After transfer to Apache, there is no need to have CLAassistant any more.
能否使用go dep或者go mod来管理包?
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.