Skip to content
Snippets Groups Projects
Commit eef15599 authored by Xin.Zh's avatar Xin.Zh Committed by GitHub
Browse files

Merge pull request #128 from fangyincheng/develop

Add:update readme
parents d5ba7d11 dc61f4a3
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
coverage.txt
*.idea
*.iml
......
......@@ -54,12 +54,23 @@ Todo List:
You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap).
## Document
Move [here](https://dubbogo.github.io/dubbo-go-website/)
## Quick Start
The subdirectory examples shows how to use dubbo-go. Please read the [examples/README.md](https://github.com/apache/dubbo-go/blob/develop/examples/README.md) carefully to learn how to dispose the configuration and compile the program.
## Running unit tests
```bash
go test ./...
# coverage
go test ./... -coverprofile=coverage.txt -covermode=atomic
```
## Contributing
If you are willing to do some code contributions and document contributions to [Apache/dubbo-go](https://github.com/apache/dubbo-go), please visit [contribution intro](https://github.com/apache/dubbo-go/blob/master/cg.md).
......
......@@ -54,10 +54,23 @@ Apache License, Version 2.0
你可以通过访问 [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap) 知道更多关于 dubbo-go 的信息
## 文档
移步[这里](https://dubbogo.github.io/dubbo-go-website/)
## 快速开始 ##
这个子目录下的例子展示了如何使用 dubbo-go 。请仔细阅读 [examples/README.md](https://github.com/apache/dubbo-go/blob/develop/examples/README.md) 学习如何处理配置并编译程序。
## 运行单测
```bash
go test ./...
# 覆盖率
go test ./... -coverprofile=coverage.txt -covermode=atomic
```
## 如何贡献
如果您愿意给 [Apache/dubbo-go](https://github.com/apache/dubbo-go) 贡献代码或者文档,我们都热烈欢迎。具体请参考 [contribution intro](https://github.com/apache/dubbo-go/blob/master/cg.md)
......
......@@ -76,22 +76,23 @@ func (s *TestService1) Reference() string {
func TestServiceMap_Register(t *testing.T) {
// lowercase
s0 := &testService{}
methods, err := ServiceMap.Register("testporotocol", s0)
// methods, err := ServiceMap.Register("testporotocol", s0)
_, err := ServiceMap.Register("testporotocol", s0)
assert.EqualError(t, err, "type testService is not exported")
// succ
s := &TestService{}
methods, err = ServiceMap.Register("testporotocol", s)
methods, err := ServiceMap.Register("testporotocol", s)
assert.NoError(t, err)
assert.Equal(t, "MethodOne,MethodThree,methodTwo", methods)
// repeat
methods, err = ServiceMap.Register("testporotocol", s)
_, err = ServiceMap.Register("testporotocol", s)
assert.EqualError(t, err, "service already defined: com.test.Path")
// no method
s1 := &TestService1{}
methods, err = ServiceMap.Register("testporotocol", s1)
_, err = ServiceMap.Register("testporotocol", s1)
assert.EqualError(t, err, "type com.test.Path1 has no exported methods of suitable type")
ServiceMap = &serviceMap{
......
......@@ -69,7 +69,7 @@ func newZookeeperDynamicConfiguration(url *common.URL) (*zookeeperDynamicConfigu
err = c.client.Create(c.rootPath)
c.listener.ListenServiceEvent(c.rootPath, c.cacheListener)
return c, nil
return c, err
}
......@@ -95,7 +95,7 @@ func newMockZookeeperDynamicConfiguration(url *common.URL, opts ...zookeeper.Opt
err = c.client.Create(c.rootPath)
go c.listener.ListenServiceEvent(c.rootPath, c.cacheListener)
return tc, c, nil
return tc, c, err
}
......
......@@ -2,8 +2,8 @@ module github.com/apache/dubbo-go
require (
github.com/dubbogo/getty v1.1.2-0.20190703052458-5e72c69fddc7
github.com/dubbogo/gost v1.0.0
github.com/dubbogo/hessian2 v1.1.2
github.com/dubbogo/gost v1.1.1
github.com/dubbogo/hessian2 v1.2.0
github.com/magiconair/properties v1.8.1
github.com/pkg/errors v0.8.1
github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec
......
......@@ -3,12 +3,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dubbogo/getty v1.1.2-0.20190703052458-5e72c69fddc7 h1:WDzbrHOfdO78mFp3RJgGRM0u2+DEwrVzo58InIdgcX8=
github.com/dubbogo/getty v1.1.2-0.20190703052458-5e72c69fddc7/go.mod h1:DfbsJXdXj6DliCAEgrRbwC7J5rz+2sOPGKKEvlF6OjE=
github.com/dubbogo/gost v1.0.0 h1:obKvpJYdrIY2BidHYwYoj2E50OtwCDqVVVTcH2nnhAY=
github.com/dubbogo/gost v1.0.0/go.mod h1:R7wZm1DrmrKGr50mBZVcg6C9ekG8aL5hP+sgWcIDwQg=
github.com/dubbogo/gost v1.1.1 h1:JCM7vx5edPIjDA5ovJTuzEEXuw2t7xLyrlgi2mi5jHI=
github.com/dubbogo/gost v1.1.1/go.mod h1:R7wZm1DrmrKGr50mBZVcg6C9ekG8aL5hP+sgWcIDwQg=
github.com/dubbogo/gostd v0.0.0-20190625030817-87d8669125b7 h1:Wmt8yQMGkNx4GDUvU4CA+dwIsDwgi+DbP28NZV2ruqQ=
github.com/dubbogo/gostd v0.0.0-20190625030817-87d8669125b7/go.mod h1:lQ7PmKvs6xplvjzEEMKw8XmP20D9raD+wFfzxkKaBd4=
github.com/dubbogo/hessian2 v1.1.2 h1:SRkPzIwVv2D+ZUOCE2XuI5kANoL01ShhAheLcc3usJE=
github.com/dubbogo/hessian2 v1.1.2/go.mod h1:XFGDn4oSZX26zkcfhkM/fCJrOqwQJxk/xgWW1KMJBKM=
github.com/dubbogo/hessian2 v1.2.0 h1:5wFYuMzzRhneUAPbVBVKubIknrEjUM/B76vievYD0Vw=
github.com/dubbogo/hessian2 v1.2.0/go.mod h1:7EohF3mE7xmZcj43nP172sapRHOEifcV/jwyHhG4SaY=
github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
......
......@@ -26,7 +26,7 @@ import (
)
import (
"github.com/dubbogo/hessian2"
hessian "github.com/dubbogo/hessian2"
perrors "github.com/pkg/errors"
"github.com/stretchr/testify/assert"
)
......
......@@ -42,7 +42,7 @@ func TestJsonClientCodec_Write(t *testing.T) {
assert.Equal(t, "{\"jsonrpc\":\"2.0\",\"method\":\"GetUser\",\"params\":[\"args\",2],\"id\":1}\n", string(data))
cd.Args = 1
data, err = codec.Write(cd)
_, err = codec.Write(cd)
assert.EqualError(t, err, "unsupported param type: int")
}
......
......@@ -211,7 +211,6 @@ func (r *zkRegistry) Register(conf common.URL) error {
role, _ := strconv.Atoi(r.URL.GetParam(constant.ROLE_KEY, ""))
switch role {
case common.CONSUMER:
ok = false
r.cltLock.Lock()
_, ok = r.services[conf.Key()]
r.cltLock.Unlock()
......@@ -232,7 +231,6 @@ func (r *zkRegistry) Register(conf common.URL) error {
case common.PROVIDER:
// 检验服务是否已经注册过
ok = false
r.cltLock.Lock()
// 注意此处与consumerZookeeperRegistry的差异,consumer用的是conf.Path,
// 因为consumer要提供watch功能给selector使用, provider允许注册同一个service的多个group or version
......
......@@ -38,9 +38,9 @@ func Test_Register(t *testing.T) {
regurl, _ := common.NewURL(context.TODO(), "registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
url, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithParamsValue("serviceid", "soa.mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
ts, reg, err := newMockZkRegistry(&regurl)
ts, reg, _ := newMockZkRegistry(&regurl)
defer ts.Stop()
err = reg.Register(url)
err := reg.Register(url)
children, _ := reg.client.GetChildren("/dubbo/com.ikurento.user.UserProvider/providers")
assert.Regexp(t, ".*dubbo%3A%2F%2F127.0.0.1%3A20000%2Fcom.ikurento.user.UserProvider%3Fanyhost%3Dtrue%26category%3Dproviders%26cluster%3Dmock%26dubbo%3Ddubbo-provider-golang-2.6.0%26.*.serviceid%3Dsoa.mock%26.*provider", children)
assert.NoError(t, err)
......@@ -49,10 +49,10 @@ func Test_Register(t *testing.T) {
func Test_Subscribe(t *testing.T) {
regurl, _ := common.NewURL(context.TODO(), "registry://127.0.0.1:1111", common.WithParamsValue(constant.ROLE_KEY, strconv.Itoa(common.PROVIDER)))
url, _ := common.NewURL(context.TODO(), "dubbo://127.0.0.1:20000/com.ikurento.user.UserProvider", common.WithParamsValue(constant.CLUSTER_KEY, "mock"), common.WithMethods([]string{"GetUser", "AddUser"}))
ts, reg, err := newMockZkRegistry(&regurl)
ts, reg, _ := newMockZkRegistry(&regurl)
//provider register
err = reg.Register(url)
err := reg.Register(url)
assert.NoError(t, err)
if err != nil {
......@@ -61,12 +61,12 @@ func Test_Subscribe(t *testing.T) {
//consumer register
regurl.Params.Set(constant.ROLE_KEY, strconv.Itoa(common.CONSUMER))
_, reg2, err := newMockZkRegistry(&regurl, zookeeper.WithTestCluster(ts))
_, reg2, _ := newMockZkRegistry(&regurl, zookeeper.WithTestCluster(ts))
err = reg2.Register(url)
listener, err := reg2.Subscribe(url)
reg2.Register(url)
listener, _ := reg2.Subscribe(url)
serviceEvent, err := listener.Next()
serviceEvent, _ := listener.Next()
assert.NoError(t, err)
if err != nil {
return
......@@ -103,7 +103,7 @@ func Test_ProviderDestory(t *testing.T) {
defer ts.Stop()
assert.NoError(t, err)
err = reg.Register(url)
reg.Register(url)
//listener.Close()
time.Sleep(1e9)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment