diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md new file mode 100644 index 0000000000000000000000000000000000000000..3e01441f7e1e8c23db294beff4160b9e987e7f61 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -0,0 +1,19 @@ +--- +name: Bug Report +about: Report a bug +labels: kind/bug + +--- + +<!-- Please use this template while reporting a bug and provide as much info as possible. Not doing so may result in your bug not being addressed in a timely manner. Thanks! + +--> + + +**What happened**: + +**What you expected to happen**: + +**How to reproduce it (as minimally and precisely as possible)**: + +**Anything else we need to know?**: diff --git a/.github/ISSUE_TEMPLATE/enhancement.md b/.github/ISSUE_TEMPLATE/enhancement.md new file mode 100644 index 0000000000000000000000000000000000000000..6d1a6d99f94c673045ea19941a4765966d608eb5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/enhancement.md @@ -0,0 +1,11 @@ +--- +name: Enhancement Request +about: Suggest an enhancement +labels: kind/feature + +--- +<!-- Please only use this template for submitting enhancement requests --> + +**What would you like to be added**: + +**Why is this needed**: \ No newline at end of file diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000000000000000000000000000000000000..3eb1ec055f18f29a7886e01c24e10c97f88fb1e8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ +<!-- Thanks for sending a pull request! +--> + +**What this PR does**: + +**Which issue(s) this PR fixes**: +<!-- +*Automatically closes linked issue when PR is merged. +Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`. +_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_* +--> +Fixes # + +**Special notes for your reviewer**: + +**Does this PR introduce a user-facing change?**: +<!-- +If no, just write "NONE" in the release-note block below. +If yes, a release note is required: +Enter your extended release note in the block below. If the PR requires additional action from users switching to the new release, include the string "action required". +--> +```release-note + +``` \ No newline at end of file diff --git a/README.md b/README.md index 9870a7f3aa3ab8e0b22719c9d21c4857504f4f59..9af43d8d7e1cdddee1c241e148e0cf3038f2484a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# Go for Apache Dubbo [涓枃](./README_CN.md) # +# Apache Dubbo-go [涓枃](./README_CN.md) # -[](https://travis-ci.com/dubbo/go-for-apache-dubbo) -[](https://codecov.io/gh/dubbo/go-for-apache-dubbo) +[](https://travis-ci.org/apache/dubbo-go) +[](https://codecov.io/gh/apache/dubbo-go) --- Apache Dubbo Go Implementation. @@ -10,13 +10,17 @@ Apache Dubbo Go Implementation. Apache License, Version 2.0 -## Code design ## +## Release note ## -Extension module and layered code design based on dubbo (include protocol layer,registry layer,cluster layer,config layer and so on), Our goal is: you can implement these layered interfaces in a new way, and override the default implementation of dubbo-go[same go-for-apache-dubbo] by calling 'extension.SetXXX' of extension, and complete your special needs without modifying the source code. At the same time, you are welcome to contribute implementation of useful expansion to the community. +[v1.0.0 - May 29, 2019 compatible with dubbo v2.6.5](https://github.com/apache/dubbo-go/releases/tag/v1.0.0) + +## Project Architecture ## + +Both extension module and layered project architecture is according to Apache Dubbo (including protocol layer, registry layer, cluster layer, config layer and so on), the advantage of this arch is as following: you can implement these layered interfaces in your own way, override the default implementation of dubbo-go by calling 'extension.SetXXX' of extension, complete your special needs without modifying the source code. At the same time, you are welcome to contribute implementation of useful extension to the community.  -About detail design please refer to [code layered design](https://github.com/dubbo/go-for-apache-dubbo/wiki/dubbo-go-V2.6-design) +If you wanna know more about dubbo-go, please visit this reference [Project Architeture design](https://github.com/apache/dubbo-go/wiki/dubbo-go-V1.0-design) ## Feature list ## @@ -40,22 +44,26 @@ Working List: Todo List: - routing rule (dubbo v2.6.x) -- monitoring (dubbo v2.6.x) -- dynamic configuration (dubbo v2.7.x) - metrics (dubbo v2.7.x) waiting dubbo's quota +- dynamic configuration center & metadata center (dubbo v2.7.x) +- tracing (dubbo ecosystem) -You can know more about dubbo-go by its [roadmap](https://github.com/dubbo/go-for-apache-dubbo/wiki/Roadmap). +You can know more about dubbo-go by its [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap). ## Quick Start -The subdirectory examples shows how to use dubbo-go. Please read the [examples/README.md](https://github.com/dubbo/go-for-apache-dubbo/blob/develop/examples/README.md) carefully to learn how to dispose the configuration and compile the program. +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. ## Benchmark Benchmark project please refer to [go-for-apache-dubbo-benchmark](https://github.com/dubbogo/go-for-apache-dubbo-benchmark) -About dubbo-go benchmarking report, please refer to [dubbo benchmarking report](https://github.com/dubbo/go-for-apache-dubbo/wiki/pressure-test-report-for-dubbo) & [jsonrpc benchmarking report](https://github.com/dubbo/go-for-apache-dubbo/wiki/pressure-test-report-for-jsonrpc) +About dubbo-go benchmarking report, please refer to [dubbo benchmarking report](https://github.com/apache/dubbo-go/wiki/pressure-test-report-for-dubbo) & [jsonrpc benchmarking report](https://github.com/apache/dubbo-go/wiki/pressure-test-report-for-jsonrpc) -## [User List](https://github.com/dubbo/go-for-apache-dubbo/issues/2) +## [User List](https://github.com/apache/dubbo-go/issues/2)  + +## Stargazers + +[](https://starchart.cc/apache/dubbo-go) diff --git a/README_CN.md b/README_CN.md index f50408582ffbfddf413c4843d63ef67ac1c6bbef..0993828a71e39b49edbccb40a8a9ec68d725889e 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,7 +1,7 @@ -# Go for Apache Dubbo [English](./README.md) # +# Apache Dubbo-go [English](./README.md) # -[](https://travis-ci.com/dubbo/go-for-apache-dubbo) -[](https://codecov.io/gh/dubbo/go-for-apache-dubbo) +[](https://travis-ci.org/apache/dubbo-go) +[](https://codecov.io/gh/apache/dubbo-go) --- Apache Dubbo Go 璇█瀹炵幇 @@ -10,13 +10,17 @@ Apache Dubbo Go 璇█瀹炵幇 Apache License, Version 2.0 -## 浠g爜璁捐 ## +## 鍙戝竷鏃ュ織 ## + +[v1.0.0 - 2019骞�5鏈�29鏃� 鍏煎dubbo v2.6.5 鐗堟湰](https://github.com/apache/dubbo-go/releases/tag/v1.0.0) + +## 宸ョ▼鏋舵瀯 ## 鍩轰簬dubbo鐨別xtension妯″潡鍜屽垎灞傜殑浠g爜璁捐(鍖呮嫭 protocol layer, registry layer, cluster layer, config 绛夌瓑)銆傛垜浠殑鐩爣鏄細浣犲彲浠ュ杩欎簺鍒嗗眰鎺ュ彛杩涜鏂扮殑瀹炵幇锛屽苟閫氳繃璋冪敤 extension 妯″潡鐨勨€� extension.SetXXX 鈥濇柟娉曟潵瑕嗙洊 dubbo-go [鍚� go-for-apache-dubbo ]鐨勯粯璁ゅ疄鐜帮紝浠ュ畬鎴愯嚜宸辩殑鐗规畩闇€姹傝€屾棤闇€淇敼婧愪唬鐮併€傚悓鏃讹紝娆㈣繋浣犱负绀惧尯璐$尞鏈夌敤鐨勬嫇灞曞疄鐜般€�  -鍏充簬璇︾粏璁捐璇烽槄璇� [code layered design](https://github.com/dubbo/go-for-apache-dubbo/wiki/dubbo-go-V2.6-design) +鍏充簬璇︾粏璁捐璇烽槄璇� [code layered design](https://github.com/apache/dubbo-go/wiki/dubbo-go-V1.0-design) ## 鍔熻兘鍒楄〃 ## @@ -40,22 +44,27 @@ Apache License, Version 2.0 浠诲姟鍒楄〃: - routing rule (dubbo v2.6.x) -- monitoring (dubbo v2.6.x) -- dynamic configuration (dubbo v2.7.x) - metrics (dubbo v2.7.x) waiting dubbo's quota +- dynamic configuration center & metadata center (dubbo v2.7.x) +- tracing (dubbo ecosystem) -浣犲彲浠ラ€氳繃璁块棶 [roadmap](https://github.com/dubbo/go-for-apache-dubbo/wiki/Roadmap) 鐭ラ亾鏇村鍏充簬 dubbo-go 鐨勪俊鎭� +浣犲彲浠ラ€氳繃璁块棶 [roadmap](https://github.com/apache/dubbo-go/wiki/Roadmap) 鐭ラ亾鏇村鍏充簬 dubbo-go 鐨勪俊鎭� ## 蹇€熷紑濮� ## -杩欎釜瀛愮洰褰曚笅鐨勪緥瀛愬睍绀轰簡濡備綍浣跨敤 dubbo-go 銆傝浠旂粏闃呰 [examples/README.md](https://github.com/dubbo/go-for-apache-dubbo/blob/develop/examples/README.md) 瀛︿範濡備綍澶勭悊閰嶇疆骞剁紪璇戠▼搴忋€� +杩欎釜瀛愮洰褰曚笅鐨勪緥瀛愬睍绀轰簡濡備綍浣跨敤 dubbo-go 銆傝浠旂粏闃呰 [examples/README.md](https://github.com/apache/dubbo-go/blob/develop/examples/README.md) 瀛︿範濡備綍澶勭悊閰嶇疆骞剁紪璇戠▼搴忋€� ## 鎬ц兘娴嬭瘯 ## 鎬ц兘娴嬭瘯椤圭洰鏄� [go-for-apache-dubbo-benchmark](https://github.com/dubbogo/go-for-apache-dubbo-benchmark) -鍏充簬 dubbo-go 鎬ц兘娴嬭瘯鎶ュ憡锛岃闃呰 [dubbo benchmarking report](https://github.com/dubbo/go-for-apache-dubbo/wiki/pressure-test-report-for-dubbo) & [jsonrpc benchmarking report](https://github.com/dubbo/go-for-apache-dubbo/wiki/pressure-test-report-for-jsonrpc) +鍏充簬 dubbo-go 鎬ц兘娴嬭瘯鎶ュ憡锛岃闃呰 [dubbo benchmarking report](https://github.com/apache/dubbo-go/wiki/pressure-test-report-for-dubbo) & [jsonrpc benchmarking report](https://github.com/apache/dubbo-go/wiki/pressure-test-report-for-jsonrpc) -## [User List](https://github.com/dubbo/go-for-apache-dubbo/issues/2) +## [User List](https://github.com/apache/dubbo-go/issues/2)  + +## Stargazers + +[](https://starchart.cc/apache/dubbo-go) + diff --git a/cluster/cluster.go b/cluster/cluster.go index a9a6c2e5972f44c50180f39c42f27b6aa681546f..d89df5a21954d63552b857d988fa9a9e7d1fcfb5 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -1,20 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster -import "github.com/dubbo/go-for-apache-dubbo/protocol" +import ( + "github.com/apache/dubbo-go/protocol" +) type Cluster interface { Join(Directory) protocol.Invoker diff --git a/cluster/cluster_impl/base_cluster_invoker.go b/cluster/cluster_impl/base_cluster_invoker.go index 3b0c587cce9eba4825fdb566c3c790c41c805c09..6cbed7748e496afb37f9a1e93dbc40e845c62b06 100644 --- a/cluster/cluster_impl/base_cluster_invoker.go +++ b/cluster/cluster_impl/base_cluster_invoker.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl @@ -20,11 +23,11 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/utils" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/version" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/utils" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/version" ) type baseClusterInvoker struct { diff --git a/cluster/cluster_impl/failover_cluster.go b/cluster/cluster_impl/failover_cluster.go index 2f2bfdfe36e2943a9757b46c3218116e583a01d6..0f1aa0371f57df5414a04a59e2a6772a4cd382b3 100644 --- a/cluster/cluster_impl/failover_cluster.go +++ b/cluster/cluster_impl/failover_cluster.go @@ -1,27 +1,29 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" ) -type failoverCluster struct { -} +type failoverCluster struct{} const name = "failover" diff --git a/cluster/cluster_impl/failover_cluster_invoker.go b/cluster/cluster_impl/failover_cluster_invoker.go index 5bb2471e06c967159196d754fe04158ad3a96c6b..cd17a85e00a1d4307b3b861467051e9719345d1a 100644 --- a/cluster/cluster_impl/failover_cluster_invoker.go +++ b/cluster/cluster_impl/failover_cluster_invoker.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl @@ -19,12 +22,12 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/utils" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/version" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/utils" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/version" ) type failoverClusterInvoker struct { diff --git a/cluster/cluster_impl/failover_cluster_test.go b/cluster/cluster_impl/failover_cluster_test.go index 5f0a28f0a679c42b6cd5fd2b9a9052a4722c0737..cc533ea098ee76488d2f76cbbe601b275274db83 100644 --- a/cluster/cluster_impl/failover_cluster_test.go +++ b/cluster/cluster_impl/failover_cluster_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl @@ -26,14 +29,14 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/directory" - "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/cluster/loadbalance" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) ///////////////////////////// diff --git a/cluster/cluster_impl/mock_cluster.go b/cluster/cluster_impl/mock_cluster.go index f913eb6827b56aa1795df593fee38aaedf4bded6..50b2735554b61600fb090f382f3d2920b3d445e3 100644 --- a/cluster/cluster_impl/mock_cluster.go +++ b/cluster/cluster_impl/mock_cluster.go @@ -1,26 +1,28 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/protocol" ) -type mockCluster struct { -} +type mockCluster struct{} func NewMockCluster() cluster.Cluster { return &mockCluster{} diff --git a/cluster/cluster_impl/registry_aware_cluster.go b/cluster/cluster_impl/registry_aware_cluster.go index 9f897bdf59c9b32794a7fe3038ee27e272f891e2..f4a28d6dcd5fbab8c62ee1f79bdd8576d8774a4c 100644 --- a/cluster/cluster_impl/registry_aware_cluster.go +++ b/cluster/cluster_impl/registry_aware_cluster.go @@ -1,27 +1,29 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" ) -type registryAwareCluster struct { -} +type registryAwareCluster struct{} func init() { extension.SetCluster("registryAware", NewRegistryAwareCluster) diff --git a/cluster/cluster_impl/registry_aware_cluster_invoker.go b/cluster/cluster_impl/registry_aware_cluster_invoker.go index 975ff8bdad63243188130b5772f2293c0b4e24de..5785c02489f95168d5419f0087f38b07c851a4a3 100644 --- a/cluster/cluster_impl/registry_aware_cluster_invoker.go +++ b/cluster/cluster_impl/registry_aware_cluster_invoker.go @@ -1,23 +1,26 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol" ) type registryAwareClusterInvoker struct { diff --git a/cluster/cluster_impl/registry_aware_cluster_test.go b/cluster/cluster_impl/registry_aware_cluster_test.go index 51734116a696303f4079c06ff361b200234e3aa9..4ae15cc5066c70646dee66cf4ef601202653cb07 100644 --- a/cluster/cluster_impl/registry_aware_cluster_test.go +++ b/cluster/cluster_impl/registry_aware_cluster_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster_impl @@ -24,10 +27,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/directory" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) func Test_RegAwareInvokeSuccess(t *testing.T) { diff --git a/cluster/directory.go b/cluster/directory.go index 9a055d6f580e622a68e648de0a0b2e3999773752..045296ce549b13c327b6f479ca0bd75d0b6ce131 100644 --- a/cluster/directory.go +++ b/cluster/directory.go @@ -1,22 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) // Extension - Directory diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index ef74c3511ca1b57fac91249c9b02aa94cb8a1f78..b2011977140f34d7e86d1414b7ced2d7cda23e9b 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package directory @@ -21,7 +24,7 @@ import ( "go.uber.org/atomic" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" + "github.com/apache/dubbo-go/common" ) type BaseDirectory struct { diff --git a/cluster/directory/static_directory.go b/cluster/directory/static_directory.go index 3ac567b00e37fae3923753a7577121e7a341ae1f..e7a0e6e569db620ee83521505c9568199d45fe1e 100644 --- a/cluster/directory/static_directory.go +++ b/cluster/directory/static_directory.go @@ -1,22 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package directory import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) type staticDirectory struct { diff --git a/cluster/directory/static_directory_test.go b/cluster/directory/static_directory_test.go index 929d23edefd3821ae8f6c48a3706f6036b9238d8..3ce772e8a6287aebef3fdad039e2b12be421c4e3 100644 --- a/cluster/directory/static_directory_test.go +++ b/cluster/directory/static_directory_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package directory @@ -25,9 +28,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) func Test_StaticDirList(t *testing.T) { diff --git a/cluster/loadbalance.go b/cluster/loadbalance.go index 897c7952f63047eb2a2237a0cd6baba3c6cb2dc2..9ae4e4eb808b28581d12b72829c921c4f0cc9ac8 100644 --- a/cluster/loadbalance.go +++ b/cluster/loadbalance.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster import ( - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/protocol" ) // Extension - LoadBalance diff --git a/cluster/loadbalance/random.go b/cluster/loadbalance/random.go index 992a8dfc35be600d29663aebf59e665a681025e3..919792162dc527fa8c1e5cf2911f2933fa8232ef 100644 --- a/cluster/loadbalance/random.go +++ b/cluster/loadbalance/random.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package loadbalance @@ -19,12 +22,14 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" ) -const name = "random" +const ( + name = "random" +) func init() { extension.SetLoadbalance(name, NewRandomLoadBalance) diff --git a/cluster/loadbalance/random_test.go b/cluster/loadbalance/random_test.go index 5b94f6b27218cf7a7b8000ecd2c2c1121b5a8ffd..09d3d259a903693e9c0550965fc12d2089228662 100644 --- a/cluster/loadbalance/random_test.go +++ b/cluster/loadbalance/random_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package loadbalance @@ -28,10 +31,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) func Test_RandomlbSelect(t *testing.T) { diff --git a/cluster/loadbalance/util.go b/cluster/loadbalance/util.go index fdbeb14dd31fa8b2581f46d3adacf5355b12878b..736952159d83a9f4ade2c2d0cb190b60f1ef3fbe 100644 --- a/cluster/loadbalance/util.go +++ b/cluster/loadbalance/util.go @@ -1,25 +1,29 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package loadbalance import ( "time" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol" ) func GetWeight(invoker protocol.Invoker, invocation protocol.Invocation) int64 { diff --git a/cluster/router.go b/cluster/router.go index a80efaa0b99ad51c1ad5a83b5cff6d3996d2b220..688ab58bdda75dd5f93864692472ab6a6c0cc87f 100644 --- a/cluster/router.go +++ b/cluster/router.go @@ -1,22 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cluster import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) // Extension - Router diff --git a/common/constant/default.go b/common/constant/default.go index 3ee4b1b1a5d607cdd4a6663366f1e6f20f82d0a6..85f61f30f115493d3d520f2a68f36921735055d7 100644 --- a/common/constant/default.go +++ b/common/constant/default.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package constant diff --git a/common/constant/env.go b/common/constant/env.go index 23fd9880afc932a99a411b099582459dfe1f7d16..f0e4fabe02cb09f63173bc9fe0cbf83885bdefb6 100644 --- a/common/constant/env.go +++ b/common/constant/env.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package constant diff --git a/common/constant/key.go b/common/constant/key.go index 5352c00f67f9d4fa7a6ce54e8c424ccd2cabd3d8..985dd4f80f531c107ef11cee1282da8742d7d62a 100644 --- a/common/constant/key.go +++ b/common/constant/key.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt, Yincheg Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package constant diff --git a/common/extension/cluster.go b/common/extension/cluster.go index 54b5ac59d31950c7ac42d81856f11c28f4716a19..91e9f953b505e31c1a4f448e1504a6ae50a9663f 100644 --- a/common/extension/cluster.go +++ b/common/extension/cluster.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package extension import ( - "github.com/dubbo/go-for-apache-dubbo/cluster" + "github.com/apache/dubbo-go/cluster" ) var ( diff --git a/common/extension/filter.go b/common/extension/filter.go index 263b67eae4023bdca49af4f1197af7f19ba3dab0..d6c7f6f694cc9888bd63c1d123bc57ee86f15e1f 100644 --- a/common/extension/filter.go +++ b/common/extension/filter.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package extension import ( - "github.com/dubbo/go-for-apache-dubbo/filter" + "github.com/apache/dubbo-go/filter" ) var ( diff --git a/common/extension/loadbalance.go b/common/extension/loadbalance.go index bb46c8283386351bfb8f789bedabd0fbd5e7b43d..f1f97b9399a2b33a3e06213fc0b2f84e73b002b7 100644 --- a/common/extension/loadbalance.go +++ b/common/extension/loadbalance.go @@ -1,20 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package extension -import "github.com/dubbo/go-for-apache-dubbo/cluster" +import ( + "github.com/apache/dubbo-go/cluster" +) var ( loadbalances = make(map[string]func() cluster.LoadBalance) @@ -28,5 +33,6 @@ func GetLoadbalance(name string) cluster.LoadBalance { if loadbalances[name] == nil { panic("loadbalance for " + name + " is not existing, make sure you have import the package.") } + return loadbalances[name]() } diff --git a/common/extension/protocol.go b/common/extension/protocol.go index f1ddbdeef8bb3de0207befaf3ec7063571723513..50d339476d024c04b182c38632689a99bc5c1680 100644 --- a/common/extension/protocol.go +++ b/common/extension/protocol.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package extension import ( - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/protocol" ) var ( diff --git a/common/extension/proxy_factory.go b/common/extension/proxy_factory.go index 8795ea8f975237c4d263053fb67052d5b98cff84..53cbbee54054bf8ad87964393b01ca6601106066 100644 --- a/common/extension/proxy_factory.go +++ b/common/extension/proxy_factory.go @@ -1,6 +1,25 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package extension -import "github.com/dubbo/go-for-apache-dubbo/common/proxy" +import ( + "github.com/apache/dubbo-go/common/proxy" +) var ( proxy_factories = make(map[string]func(...proxy.Option) proxy.ProxyFactory) diff --git a/common/extension/registry.go b/common/extension/registry.go index d6cacd88028bf96697e11525098454d741784351..776c2b5df542e56f8c120c850f20093a971d8602 100644 --- a/common/extension/registry.go +++ b/common/extension/registry.go @@ -1,22 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package extension import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/registry" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/registry" ) var ( diff --git a/common/logger/log.yml b/common/logger/log.yml index 427308d52b028d1740dac56b66b2e54fa76c6fe2..59fa4279ad85272c4c49d532beaf23b74d00f58a 100644 --- a/common/logger/log.yml +++ b/common/logger/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/common/logger/logger.go b/common/logger/logger.go index 22fe7329e7601b9e3701ad51c9da2eaa937a7d27..f6522c489d047a1d4ec7000565bf4cfda6a50466 100644 --- a/common/logger/logger.go +++ b/common/logger/logger.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package logger @@ -30,7 +33,7 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" + "github.com/apache/dubbo-go/common/constant" ) var ( diff --git a/common/logger/logger_test.go b/common/logger/logger_test.go index 9256aa417ae44d1ccdcc82a90abafebdf3581e79..e29b7cbc8e9bbd67df41df5ac687a079621c3360 100644 --- a/common/logger/logger_test.go +++ b/common/logger/logger_test.go @@ -1,11 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package logger import ( - "github.com/stretchr/testify/assert" + "fmt" "path/filepath" + "runtime" "testing" ) +import ( + "github.com/stretchr/testify/assert" +) + func TestInitLog(t *testing.T) { var ( err error @@ -23,7 +45,13 @@ func TestInitLog(t *testing.T) { path, err = filepath.Abs("./logger.yml") assert.NoError(t, err) err = InitLog(path) - assert.EqualError(t, err, "ioutil.ReadFile(file:"+path+") = error:open "+path+": no such file or directory") + var errMsg string + if runtime.GOOS == "windows" { + errMsg = fmt.Sprintf("open %s: The system cannot find the file specified.", path) + } else { + errMsg = fmt.Sprintf("open %s: no such file or directory", path) + } + assert.EqualError(t, err, fmt.Sprintf("ioutil.ReadFile(file:%s) = error:%s", path, errMsg)) err = InitLog("./log.yml") assert.NoError(t, err) diff --git a/common/logger/logging.go b/common/logger/logging.go index 57a0e04e42252d343391cbfe04fd4edef92da3f0..4638c9a41dfe986d256e1ff4d52b690c1747fc94 100644 --- a/common/logger/logging.go +++ b/common/logger/logging.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package logger diff --git a/common/node.go b/common/node.go index fb409e5cee177f2b927afd84bda7b333549511eb..992ead38d8acf85bbb14f02eebca4c4fe5a0a1e2 100644 --- a/common/node.go +++ b/common/node.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package common diff --git a/common/proxy/proxy.go b/common/proxy/proxy.go index 033c8687ee25d4ded826b9a6a1315608b7b8c4ab..fe4c003306360af928a0b1a6612042e9811a9af3 100644 --- a/common/proxy/proxy.go +++ b/common/proxy/proxy.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package proxy @@ -19,10 +22,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" - invocation_impl "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + invocation_impl "github.com/apache/dubbo-go/protocol/invocation" ) // Proxy struct diff --git a/common/proxy/proxy_factory.go b/common/proxy/proxy_factory.go index 4d7fa52b7451b0c014d2ffdc3f0383acb6c777d4..2567e0ee09cf7fa5aef7fde46872eb88205d8e45 100644 --- a/common/proxy/proxy_factory.go +++ b/common/proxy/proxy_factory.go @@ -1,21 +1,25 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package proxy import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) type ProxyFactory interface { diff --git a/common/proxy/proxy_factory/default.go b/common/proxy/proxy_factory/default.go index 54ba45392bea7bcbb578178845ca781dbffe3cb5..016bbcf514514e3bea67d87c83f01aebb166be23 100644 --- a/common/proxy/proxy_factory/default.go +++ b/common/proxy/proxy_factory/default.go @@ -1,24 +1,28 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package proxy_factory import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/proxy" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/proxy" + "github.com/apache/dubbo-go/protocol" ) func init() { diff --git a/common/proxy/proxy_factory/default_test.go b/common/proxy/proxy_factory/default_test.go index 385dfee636a5422ca81deee39b1195201c6edd3c..d9c8ffa2525551fc0197e2476e85b5ee51a18ec6 100644 --- a/common/proxy/proxy_factory/default_test.go +++ b/common/proxy/proxy_factory/default_test.go @@ -1,25 +1,32 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package proxy_factory import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/stretchr/testify/assert" "testing" ) +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" + "github.com/stretchr/testify/assert" +) + func Test_GetProxy(t *testing.T) { proxyFactory := NewDefaultProxyFactory() url := common.NewURLWithOptions("testservice") diff --git a/common/proxy/proxy_test.go b/common/proxy/proxy_test.go index 6a12af8a70552ec5348d75f9c57bec31670806ad..44bdaec4b845a3a864c8637ced16ac4493fc2b80 100644 --- a/common/proxy/proxy_test.go +++ b/common/proxy/proxy_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package proxy @@ -26,9 +29,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol" ) type TestService struct { diff --git a/common/rpc_service.go b/common/rpc_service.go index 3a215ab17a7c156fda7d19be3b86255d8ef06138..d8578a143eccb05696e633cc3fd61dd6f00c3bc7 100644 --- a/common/rpc_service.go +++ b/common/rpc_service.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package common @@ -28,7 +31,7 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common/logger" ) // rpc service interface diff --git a/common/rpc_service_test.go b/common/rpc_service_test.go index 41476149c09d0d44140717076c7fc8c13152b348..e5bab2c7153daeb34068c2005def6811b8478532 100644 --- a/common/rpc_service_test.go +++ b/common/rpc_service_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package common diff --git a/common/url.go b/common/url.go index 9b0c6352ae781a4f6eacb36e3f727e2b7ac55232..115167ee3ebab6718dfd8a229f2a370e5b79a982 100644 --- a/common/url.go +++ b/common/url.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package common @@ -28,7 +31,7 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" + "github.com/apache/dubbo-go/common/constant" ) ///////////////////////////////// @@ -292,3 +295,52 @@ func (c URL) GetMethodParam(method string, key string, d string) string { } return r } + +// configuration > reference config >service config +// in this function we should merge the reference local url config into the service url from registry. +//TODO configuration merge, in the future , the configuration center's config should merge too. +func MergeUrl(serviceUrl URL, referenceUrl *URL) URL { + mergedUrl := serviceUrl + var methodConfigMergeFcn = []func(method string){} + //iterator the referenceUrl if serviceUrl not have the key ,merge in + + for k, v := range referenceUrl.Params { + if _, ok := mergedUrl.Params[k]; !ok { + mergedUrl.Params.Set(k, v[0]) + } + } + //loadBalance strategy config + if v := referenceUrl.Params.Get(constant.LOADBALANCE_KEY); v != "" { + mergedUrl.Params.Set(constant.LOADBALANCE_KEY, v) + } + methodConfigMergeFcn = append(methodConfigMergeFcn, func(method string) { + if v := referenceUrl.Params.Get(method + "." + constant.LOADBALANCE_KEY); v != "" { + mergedUrl.Params.Set(method+"."+constant.LOADBALANCE_KEY, v) + } + }) + + //cluster strategy config + if v := referenceUrl.Params.Get(constant.CLUSTER_KEY); v != "" { + mergedUrl.Params.Set(constant.CLUSTER_KEY, v) + } + methodConfigMergeFcn = append(methodConfigMergeFcn, func(method string) { + if v := referenceUrl.Params.Get(method + "." + constant.CLUSTER_KEY); v != "" { + mergedUrl.Params.Set(method+"."+constant.CLUSTER_KEY, v) + } + }) + + //remote timestamp + if v := serviceUrl.Params.Get(constant.TIMESTAMP_KEY); v != "" { + mergedUrl.Params.Set(constant.REMOTE_TIMESTAMP_KEY, v) + mergedUrl.Params.Set(constant.TIMESTAMP_KEY, referenceUrl.Params.Get(constant.TIMESTAMP_KEY)) + } + + //finally execute methodConfigMergeFcn + for _, method := range referenceUrl.Methods { + for _, fcn := range methodConfigMergeFcn { + fcn("methods." + method) + } + } + + return mergedUrl +} diff --git a/common/url_test.go b/common/url_test.go index cfac4703ef8c2c6443efbc0562c98add8acd5466..1093516ce5f5ccedcee2ab22898e0124eae0eca2 100644 --- a/common/url_test.go +++ b/common/url_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package common @@ -21,6 +24,7 @@ import ( ) import ( + "github.com/apache/dubbo-go/common/constant" "github.com/stretchr/testify/assert" ) @@ -133,3 +137,19 @@ func TestURL_GetMethodParam(t *testing.T) { v = u.GetMethodParam("GetValue", "timeout", "1s") assert.Equal(t, "1s", v) } + +func TestMergeUrl(t *testing.T) { + referenceUrlParams := url.Values{} + referenceUrlParams.Set(constant.CLUSTER_KEY, "random") + referenceUrlParams.Set("test3", "1") + serviceUrlParams := url.Values{} + serviceUrlParams.Set("test2", "1") + serviceUrlParams.Set(constant.CLUSTER_KEY, "roundrobin") + referenceUrl, _ := NewURL(context.TODO(), "mock1://127.0.0.1:1111", WithParams(referenceUrlParams)) + serviceUrl, _ := NewURL(context.TODO(), "mock2://127.0.0.1:20000", WithParams(serviceUrlParams)) + + mergedUrl := MergeUrl(serviceUrl, &referenceUrl) + assert.Equal(t, "random", mergedUrl.GetParam(constant.CLUSTER_KEY, "")) + assert.Equal(t, "1", mergedUrl.GetParam("test2", "")) + assert.Equal(t, "1", mergedUrl.GetParam("test3", "")) +} diff --git a/common/utils/net.go b/common/utils/net.go index b9f1786e2bfea4337d28c0d963940558f6c3ecc2..41d7b9e2e57d3e8ca0e2818da518737b5cf39b3f 100644 --- a/common/utils/net.go +++ b/common/utils/net.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package utils diff --git a/common/utils/net_test.go b/common/utils/net_test.go index 5230d8d9c91f37d79e2d846f243ca1fcb68d758a..d50c437f8462f9ac8cc2b64df136d5d9aed67c8a 100644 --- a/common/utils/net_test.go +++ b/common/utils/net_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package utils import ( diff --git a/common/utils/strings.go b/common/utils/strings.go new file mode 100644 index 0000000000000000000000000000000000000000..ec5d118e9137f1818e1fe64ee3bc90d52080a3a8 --- /dev/null +++ b/common/utils/strings.go @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package utils + +import ( + "regexp" +) + +func RegSplit(text string, delimeter string) []string { + reg := regexp.MustCompile(delimeter) + indexes := reg.FindAllStringIndex(text, -1) + laststart := 0 + result := make([]string, len(indexes)+1) + for i, element := range indexes { + result[i] = text[laststart:element[0]] + laststart = element[1] + } + result[len(indexes)] = text[laststart:len(text)] + return result +} diff --git a/common/utils/strings_test.go b/common/utils/strings_test.go new file mode 100644 index 0000000000000000000000000000000000000000..345ffd0c25d4398d63922115061697e148cb0a43 --- /dev/null +++ b/common/utils/strings_test.go @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package utils + +import ( + "testing" +) +import ( + "github.com/stretchr/testify/assert" +) + +func Test_RegSplit(t *testing.T) { + strings := RegSplit("dubbo://123.1.2.1;jsonrpc://127.0.0.1;registry://3.2.1.3?registry=zookeeper", "\\s*[;]+\\s*") + assert.Len(t, strings, 3) + assert.Equal(t, "dubbo://123.1.2.1", strings[0]) + assert.Equal(t, "jsonrpc://127.0.0.1", strings[1]) + assert.Equal(t, "registry://3.2.1.3?registry=zookeeper", strings[2]) +} diff --git a/config/application_config.go b/config/application_config.go index f12fdea9f1d332931d646a3a124ef522f6aef5e8..ae9716d2d07a7961b9eed995234025e062496a19 100644 --- a/config/application_config.go +++ b/config/application_config.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config diff --git a/config/config_loader.go b/config/config_loader.go index 32dde08bd1a867f84b937bc1de83456073e563a8..2560b78bd15686d221cdb7f2e0e613954688e20e 100644 --- a/config/config_loader.go +++ b/config/config_loader.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config @@ -30,9 +33,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/version" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/version" ) var ( @@ -169,6 +172,9 @@ type ProviderConfig struct { ProtocolConf interface{} `yaml:"protocol_conf" json:"protocol_conf,omitempty"` } +func SetProviderConfig(p ProviderConfig) { + providerConfig = &p +} func GetProviderConfig() ProviderConfig { if providerConfig == nil { logger.Warnf("providerConfig is nil!") diff --git a/config/config_loader_test.go b/config/config_loader_test.go index 0fcd76b95535c09770a0a72e6a8ca8f5f5007d7a..7c3343fd35a1ce9d3e519d3f45435be775755bdf 100644 --- a/config/config_loader_test.go +++ b/config/config_loader_test.go @@ -1,21 +1,23 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config import ( - "github.com/dubbo/go-for-apache-dubbo/common/proxy/proxy_factory" "path/filepath" "testing" ) @@ -25,9 +27,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/extension" + "github.com/apache/dubbo-go/cluster/cluster_impl" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/proxy/proxy_factory" ) func TestConfigLoader(t *testing.T) { diff --git a/config/config_utils.go b/config/config_utils.go index 5b2e2053ce5c2aac9312c8112e5c234764b394d1..90837344cae7cead935308e77d350868015f89d4 100644 --- a/config/config_utils.go +++ b/config/config_utils.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package config import ( @@ -5,7 +22,7 @@ import ( "strings" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" + "github.com/apache/dubbo-go/common/constant" ) func mergeValue(str1, str2, def string) string { diff --git a/config/config_utils_test.go b/config/config_utils_test.go index 2c80f9da4f7d5fcc5537acc50cbd307180a0032a..5170b90c83a0f31bbbe1b5de5bca9b8dc5869ac6 100644 --- a/config/config_utils_test.go +++ b/config/config_utils_test.go @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package config import ( diff --git a/config/mock_rpcservice.go b/config/mock_rpcservice.go index 87059ac007d736f19bbeea579a18a41b407a9560..0b3b9f22b497c66067eff5969b8dca044a34735a 100644 --- a/config/mock_rpcservice.go +++ b/config/mock_rpcservice.go @@ -1,33 +1,40 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config -import "context" +import ( + "context" +) -type MockService struct { -} +type MockService struct{} func (*MockService) Service() string { return "MockService" } + func (*MockService) Version() string { return "1.0" } + func (*MockService) GetUser(ctx context.Context, itf []interface{}, str *struct{}) error { return nil } + func (*MockService) GetUser1(ctx context.Context, itf []interface{}, str *struct{}) error { return nil } diff --git a/config/reference_config.go b/config/reference_config.go index af57cc5114a744c417848500bfd25784880f33c7..e0c93b3e54248e886982dbf49e13a42a063eee77 100644 --- a/config/reference_config.go +++ b/config/reference_config.go @@ -1,33 +1,38 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config import ( "context" + "fmt" "net/url" "strconv" "time" ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/directory" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/proxy" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/proxy" + "github.com/apache/dubbo-go/common/utils" + "github.com/apache/dubbo-go/protocol" ) type ReferenceConfig struct { @@ -35,6 +40,7 @@ type ReferenceConfig struct { pxy *proxy.Proxy InterfaceName string `required:"true" yaml:"interface" json:"interface,omitempty"` Check *bool `yaml:"check" json:"check,omitempty"` + Url string `yaml:"url" json:"url,omitempty"` Filter string `yaml:"filter" json:"filter,omitempty"` Protocol string `yaml:"protocol" json:"protocol,omitempty"` Registries []ConfigRegistry `required:"true" yaml:"registries" json:"registries,omitempty"` @@ -50,6 +56,7 @@ type ReferenceConfig struct { } `yaml:"methods" json:"methods,omitempty"` async bool `yaml:"async" json:"async,omitempty"` invoker protocol.Invoker + urls []*common.URL } type ConfigRegistry string @@ -57,6 +64,7 @@ type ConfigRegistry string func NewReferenceConfig(ctx context.Context) *ReferenceConfig { return &ReferenceConfig{context: ctx} } + func (refconfig *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { type rf ReferenceConfig raw := rf{} // Put your defaults here @@ -67,28 +75,59 @@ func (refconfig *ReferenceConfig) UnmarshalYAML(unmarshal func(interface{}) erro *refconfig = ReferenceConfig(raw) return nil } -func (refconfig *ReferenceConfig) Refer() { - //1. user specified SubURL, could be peer-to-peer address, or register center's address. - //2. assemble SubURL from register center's configuration妯″紡 - regUrls := loadRegistries(refconfig.Registries, consumerConfig.Registries, common.CONSUMER) +func (refconfig *ReferenceConfig) Refer() { url := common.NewURLWithOptions(refconfig.InterfaceName, common.WithProtocol(refconfig.Protocol), common.WithParams(refconfig.getUrlMap())) - //set url to regUrls - for _, regUrl := range regUrls { - regUrl.SubURL = url - } + //1. user specified URL, could be peer-to-peer address, or register center's address. + if refconfig.Url != "" { + urlStrings := utils.RegSplit(refconfig.Url, "\\s*[;]+\\s*") + for _, urlStr := range urlStrings { + serviceUrl, err := common.NewURL(context.Background(), urlStr) + if err != nil { + panic(fmt.Sprintf("user specified URL %v refer error, error message is %v ", urlStr, err.Error())) + } + if serviceUrl.Protocol == constant.REGISTRY_PROTOCOL { + serviceUrl.SubURL = url + refconfig.urls = append(refconfig.urls, &serviceUrl) + } else { + if serviceUrl.Path == "" { + serviceUrl.Path = "/" + refconfig.InterfaceName + } + // merge url need to do + newUrl := common.MergeUrl(serviceUrl, url) + refconfig.urls = append(refconfig.urls, &newUrl) + } + + } + } else { + //2. assemble SubURL from register center's configuration妯″紡 + refconfig.urls = loadRegistries(refconfig.Registries, consumerConfig.Registries, common.CONSUMER) - if len(regUrls) == 1 { - refconfig.invoker = extension.GetProtocol("registry").Refer(*regUrls[0]) + //set url to regUrls + for _, regUrl := range refconfig.urls { + regUrl.SubURL = url + } + } + if len(refconfig.urls) == 1 { + refconfig.invoker = extension.GetProtocol(refconfig.urls[0].Protocol).Refer(*refconfig.urls[0]) } else { invokers := []protocol.Invoker{} - for _, regUrl := range regUrls { - invokers = append(invokers, extension.GetProtocol("registry").Refer(*regUrl)) + var regUrl *common.URL + for _, u := range refconfig.urls { + invokers = append(invokers, extension.GetProtocol(u.Protocol).Refer(*u)) + if u.Protocol == constant.REGISTRY_PROTOCOL { + regUrl = u + } + } + if regUrl != nil { + cluster := extension.GetCluster("registryAware") + refconfig.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) + } else { + cluster := extension.GetCluster(refconfig.Cluster) + refconfig.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) } - cluster := extension.GetCluster("registryAware") - refconfig.invoker = cluster.Join(directory.NewStaticDirectory(invokers)) } //create proxy diff --git a/config/reference_config_test.go b/config/reference_config_test.go index 8d1c718f830923a63b79439cd0ba865d23e9ddca..fc583605638458a03ab1d2b435429d95ca7ce43d 100644 --- a/config/reference_config_test.go +++ b/config/reference_config_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config @@ -24,10 +27,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/cluster/cluster_impl" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" ) var regProtocol protocol.Protocol @@ -136,6 +139,44 @@ func Test_Refer(t *testing.T) { } consumerConfig = nil } +func Test_ReferP2P(t *testing.T) { + doInit() + extension.SetProtocol("dubbo", GetProtocol) + consumerConfig.References[0].Url = "dubbo://127.0.0.1:20000" + + for _, reference := range consumerConfig.References { + reference.Refer() + assert.NotNil(t, reference.invoker) + assert.NotNil(t, reference.pxy) + } + consumerConfig = nil +} +func Test_ReferMultiP2P(t *testing.T) { + doInit() + extension.SetProtocol("dubbo", GetProtocol) + consumerConfig.References[0].Url = "dubbo://127.0.0.1:20000;dubbo://127.0.0.2:20000" + + for _, reference := range consumerConfig.References { + reference.Refer() + assert.NotNil(t, reference.invoker) + assert.NotNil(t, reference.pxy) + } + consumerConfig = nil +} + +func Test_ReferMultiP2PWithReg(t *testing.T) { + doInit() + extension.SetProtocol("dubbo", GetProtocol) + extension.SetProtocol("registry", GetProtocol) + consumerConfig.References[0].Url = "dubbo://127.0.0.1:20000;registry://127.0.0.2:20000" + + for _, reference := range consumerConfig.References { + reference.Refer() + assert.NotNil(t, reference.invoker) + assert.NotNil(t, reference.pxy) + } + consumerConfig = nil +} func Test_Implement(t *testing.T) { doInit() @@ -149,6 +190,7 @@ func Test_Implement(t *testing.T) { } consumerConfig = nil } + func GetProtocol() protocol.Protocol { if regProtocol != nil { return regProtocol @@ -160,8 +202,7 @@ func newRegistryProtocol() protocol.Protocol { return &mockRegistryProtocol{} } -type mockRegistryProtocol struct { -} +type mockRegistryProtocol struct{} func (*mockRegistryProtocol) Refer(url common.URL) protocol.Invoker { return protocol.NewBaseInvoker(url) @@ -171,6 +212,4 @@ func (*mockRegistryProtocol) Export(invoker protocol.Invoker) protocol.Exporter return protocol.NewBaseExporter("test", invoker, &sync.Map{}) } -func (*mockRegistryProtocol) Destroy() { - -} +func (*mockRegistryProtocol) Destroy() {} diff --git a/config/registry_config.go b/config/registry_config.go index 550b73544fa055b044d5bb4305bdd3624beefd67..6dcf5bde757057df1eeab39c36cf54b142af1f32 100644 --- a/config/registry_config.go +++ b/config/registry_config.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config @@ -21,9 +24,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" ) type RegistryConfig struct { @@ -43,8 +46,12 @@ func loadRegistries(registriesIds []ConfigRegistry, registries []RegistryConfig, for _, registryConf := range registries { if string(registry) == registryConf.Id { - url, err := common.NewURL(context.TODO(), constant.REGISTRY_PROTOCOL+"://"+registryConf.Address, common.WithParams(registryConf.getUrlMap(roleType)), - common.WithUsername(registryConf.Username), common.WithPassword(registryConf.Password), + url, err := common.NewURL( + context.TODO(), + constant.REGISTRY_PROTOCOL+"://"+registryConf.Address, + common.WithParams(registryConf.getUrlMap(roleType)), + common.WithUsername(registryConf.Username), + common.WithPassword(registryConf.Password), ) if err != nil { @@ -66,5 +73,6 @@ func (regconfig *RegistryConfig) getUrlMap(roleType common.RoleType) url.Values urlMap.Set(constant.ROLE_KEY, strconv.Itoa(int(roleType))) urlMap.Set(constant.REGISTRY_KEY, regconfig.Type) urlMap.Set(constant.REGISTRY_TIMEOUT_KEY, regconfig.TimeoutStr) + return urlMap } diff --git a/config/service.go b/config/service.go index 507bee4542a666de63d946509c15e320a876ed8b..0f3356f710dc89f25db102d73026e2bde9b9f466 100644 --- a/config/service.go +++ b/config/service.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config import ( - "github.com/dubbo/go-for-apache-dubbo/common" + "github.com/apache/dubbo-go/common" ) var ( diff --git a/config/service_config.go b/config/service_config.go index 0391a17dd1ef397870ad2fb8288a9b5cbab35bfd..9db0f99facbc69671153a713b5ff4a347e32d749 100644 --- a/config/service_config.go +++ b/config/service_config.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config @@ -22,16 +25,18 @@ import ( "sync" "time" ) + import ( perrors "github.com/pkg/errors" "go.uber.org/atomic" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" ) type ServiceConfig struct { diff --git a/config/service_config_test.go b/config/service_config_test.go index bed7cc5b954c21f9700bff6424ac7c73e7f69df3..77cbbff386fcee1e27b59bc7e2718a8d1929af38 100644 --- a/config/service_config_test.go +++ b/config/service_config_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package config @@ -23,7 +26,7 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/extension" + "github.com/apache/dubbo-go/common/extension" ) func doinit() { @@ -114,6 +117,7 @@ func doinit() { }, } } + func Test_Export(t *testing.T) { doinit() extension.SetProtocol("registry", GetProtocol) diff --git a/config/testdata/consumer_config.yml b/config/testdata/consumer_config.yml index 8a9aeafac99da3a51a58a2dc7815b089987c867f..9095c44d4f821119e85e2225a5ee858abbea80a5 100644 --- a/config/testdata/consumer_config.yml +++ b/config/testdata/consumer_config.yml @@ -17,31 +17,32 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" - filter: "" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + - registries : + - "hangzhouzk" + - "shanghaizk" + filter: "" + protocol : "dubbo" + interface : "com.ikurento.user.UserProvider" + url: "dubbo://127.0.0.1:20000" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 protocol_conf: dubbo: diff --git a/config/testdata/provider_config.yml b/config/testdata/provider_config.yml index 6c7da063695886c934eb92a300135f5374a0aa7f..b02384798fc06f7d7e6e9ca919315a09dd1d47da 100644 --- a/config/testdata/provider_config.yml +++ b/config/testdata/provider_config.yml @@ -11,45 +11,45 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" services: -- registries: - - "hangzhouzk" - - "shanghaizk" - filter: "" - protocol : "dubbo" - # equivalent to interface of dubbo.xml - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 + - registries: + - "hangzhouzk" + - "shanghaizk" + filter: "" + protocol : "dubbo" + # equivalent to interface of dubbo.xml + interface : "com.ikurento.user.UserProvider" loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -- name: "dubbo" - # while using dubbo protocol, ip cannot is 127.0.0.1, because client of java-dubbo will get 'connection refuse' - ip : "127.0.0.1" - port : 20000 -#- name: "jsonrpc" -# ip: "127.0.0.1" -# port: 20001 + - name: "dubbo" + # while using dubbo protocol, ip cannot is 127.0.0.1, because client of java-dubbo will get 'connection refuse' + ip : "127.0.0.1" + port : 20000 + #- name: "jsonrpc" + # ip: "127.0.0.1" + # port: 20001 protocol_conf: dubbo: diff --git a/examples/dubbo/go-client/app/client.go b/examples/dubbo/go-client/app/client.go index c95654267dd6ba2a8400888e0fcb6d299fad0cf8..25b3263ac5c916df585031438b9c489b83cefb3c 100644 --- a/examples/dubbo/go-client/app/client.go +++ b/examples/dubbo/go-client/app/client.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -24,21 +27,21 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" "github.com/dubbogo/hessian2" ) import ( - _ "github.com/dubbo/go-for-apache-dubbo/common/proxy/proxy_factory" - "github.com/dubbo/go-for-apache-dubbo/config" - _ "github.com/dubbo/go-for-apache-dubbo/protocol/dubbo" - _ "github.com/dubbo/go-for-apache-dubbo/registry/protocol" + "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" - _ "github.com/dubbo/go-for-apache-dubbo/filter/impl" + _ "github.com/apache/dubbo-go/filter/impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance" - _ "github.com/dubbo/go-for-apache-dubbo/registry/zookeeper" + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" ) var ( @@ -90,7 +93,7 @@ func main() { } println("response result: %v", ret1) - println("\n\n\nstart to test dubbo - getUser") + println("\n\n\nstart to test dubbo - getUser2") user = &User{} err = conMap["com.ikurento.user.UserProvider"].GetRPCService().(*UserProvider).GetUser2(context.TODO(), []interface{}{1}, user) if err != nil { @@ -99,6 +102,13 @@ func main() { println("response result: %v", user) } + println("\n\n\nstart to test dubbo - getErr") + user = &User{} + err = conMap["com.ikurento.user.UserProvider"].GetRPCService().(*UserProvider).GetErr(context.TODO(), []interface{}{"A003"}, user) + if err != nil { + println("getErr - error: %v", err) + } + println("\n\n\nstart to test dubbo illegal method") err = conMap["com.ikurento.user.UserProvider"].GetRPCService().(*UserProvider).GetUser1(context.TODO(), []interface{}{"A003"}, user) if err != nil { diff --git a/examples/dubbo/go-client/app/user.go b/examples/dubbo/go-client/app/user.go index 7e9d3daedf756b79318160995ace0d8222b39b05..59e105109ecb7213a071ca9071737e14fff0869e 100644 --- a/examples/dubbo/go-client/app/user.go +++ b/examples/dubbo/go-client/app/user.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -22,11 +25,11 @@ import ( ) import ( - "github.com/dubbogo/hessian2" + hessian "github.com/dubbogo/hessian2" ) import ( - "github.com/dubbo/go-for-apache-dubbo/config" + "github.com/apache/dubbo-go/config" ) type Gender hessian.JavaEnum @@ -94,6 +97,7 @@ func (User) JavaClassName() string { type UserProvider struct { GetUsers func(req []interface{}) ([]interface{}, error) + GetErr func(ctx context.Context, req []interface{}, rsp *User) error GetUser func(ctx context.Context, req []interface{}, rsp *User) error GetUser0 func(id string, name string) (User, error) GetUser1 func(ctx context.Context, req []interface{}, rsp *User) error diff --git a/examples/dubbo/go-client/app/version.go b/examples/dubbo/go-client/app/version.go index 33bb9cd02dd53fdbd84f9f96942cf2dc9c1ef115..c6138584f1ddeab3a4927774f44f9e78a8f08da7 100644 --- a/examples/dubbo/go-client/app/version.go +++ b/examples/dubbo/go-client/app/version.go @@ -1,5 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main var ( - Version = "0.3.1" + Version = "2.6.0" ) diff --git a/examples/dubbo/go-client/assembly/common/build.sh b/examples/dubbo/go-client/assembly/common/build.sh index 00763725b821e54dd0f378b0ec60757837067ef9..e72418297ad2f0ac6985476b5a8d5e03b9e7584e 100644 --- a/examples/dubbo/go-client/assembly/common/build.sh +++ b/examples/dubbo/go-client/assembly/common/build.sh @@ -15,7 +15,7 @@ PROJECT_HOME=`pwd` TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` if [[ ${GOOS} == "windows" ]]; then TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe fi diff --git a/examples/dubbo/go-client/profiles/dev/client.yml b/examples/dubbo/go-client/profiles/dev/client.yml index 93ce354c9c65682d393619a6afa1ae449b96660d..3fcbd2cb15cd4217a8900a148753b8a7337ac553 100644 --- a/examples/dubbo/go-client/profiles/dev/client.yml +++ b/examples/dubbo/go-client/profiles/dev/client.yml @@ -15,31 +15,32 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" + - registries : + - "hangzhouzk" + - "shanghaizk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + protocol : "dubbo" + # url: "dubbo://127.0.0.1:20000" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 protocol_conf: dubbo: diff --git a/examples/dubbo/go-client/profiles/dev/log.yml b/examples/dubbo/go-client/profiles/dev/log.yml index 427308d52b028d1740dac56b66b2e54fa76c6fe2..59fa4279ad85272c4c49d532beaf23b74d00f58a 100644 --- a/examples/dubbo/go-client/profiles/dev/log.yml +++ b/examples/dubbo/go-client/profiles/dev/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/dubbo/go-client/profiles/release/client.yml b/examples/dubbo/go-client/profiles/release/client.yml index cb36b6946c3d5c637e291c47e34a779aaf427553..998f232fcac87da0b793ca2c062cf6cf6de8f6f3 100644 --- a/examples/dubbo/go-client/profiles/release/client.yml +++ b/examples/dubbo/go-client/profiles/release/client.yml @@ -15,31 +15,31 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" + - registries : + - "hangzhouzk" + - "shanghaizk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + protocol : "dubbo" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 protocol_conf: dubbo: diff --git a/examples/dubbo/go-client/profiles/release/log.yml b/examples/dubbo/go-client/profiles/release/log.yml index b9139c2e9cb21d5f557eb53e5d6909fca64ac205..e0514be020eedf594d99d112183cdd5ce199e46d 100644 --- a/examples/dubbo/go-client/profiles/release/log.yml +++ b/examples/dubbo/go-client/profiles/release/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/dubbo/go-client/profiles/test/client.yml b/examples/dubbo/go-client/profiles/test/client.yml index cb36b6946c3d5c637e291c47e34a779aaf427553..998f232fcac87da0b793ca2c062cf6cf6de8f6f3 100644 --- a/examples/dubbo/go-client/profiles/test/client.yml +++ b/examples/dubbo/go-client/profiles/test/client.yml @@ -15,31 +15,31 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" + - registries : + - "hangzhouzk" + - "shanghaizk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + protocol : "dubbo" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 protocol_conf: dubbo: diff --git a/examples/dubbo/go-client/profiles/test/log.yml b/examples/dubbo/go-client/profiles/test/log.yml index d2e1d05f3f46bc4ec6c7b8a16211c13d2189219d..baee0b7248484e425f88f35ab128212c931ff85e 100644 --- a/examples/dubbo/go-client/profiles/test/log.yml +++ b/examples/dubbo/go-client/profiles/test/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/dubbo/go-server/app/server.go b/examples/dubbo/go-server/app/server.go index 1c0d2c2c7391a417177332ab7341d80ade7a4faf..a5c89be7a6b36ddaaae8b515729aaccd203c19f1 100644 --- a/examples/dubbo/go-server/app/server.go +++ b/examples/dubbo/go-server/app/server.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -23,21 +26,21 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbogo/hessian2" + hessian "github.com/dubbogo/hessian2" ) import ( - "github.com/dubbo/go-for-apache-dubbo/config" - _ "github.com/dubbo/go-for-apache-dubbo/protocol/dubbo" - _ "github.com/dubbo/go-for-apache-dubbo/registry/protocol" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" - _ "github.com/dubbo/go-for-apache-dubbo/common/proxy/proxy_factory" - _ "github.com/dubbo/go-for-apache-dubbo/filter/impl" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + _ "github.com/apache/dubbo-go/filter/impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance" - _ "github.com/dubbo/go-for-apache-dubbo/registry/zookeeper" + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" ) var ( diff --git a/examples/dubbo/go-server/app/user.go b/examples/dubbo/go-server/app/user.go index 427125bd1329668c24e9dc46a94d55cfb362a472..e4400cc270ad46c84085b52e8879bbd49969bcb0 100644 --- a/examples/dubbo/go-server/app/user.go +++ b/examples/dubbo/go-server/app/user.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -22,12 +25,12 @@ import ( ) import ( - "github.com/dubbogo/hessian2" perrors "github.com/pkg/errors" ) import ( - "github.com/dubbo/go-for-apache-dubbo/config" + "github.com/apache/dubbo-go/config" + hessian "github.com/dubbogo/hessian2" ) type Gender hessian.JavaEnum @@ -142,6 +145,10 @@ func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User return err } +func (u *UserProvider) GetErr(ctx context.Context, req []interface{}, rsp *User) error { + return hessian.NewThrowable("exception") +} + func (u *UserProvider) GetUser0(id string, name string) (User, error) { var err error diff --git a/examples/dubbo/go-server/app/version.go b/examples/dubbo/go-server/app/version.go index c7552b26e11ec15fd51f3e18905d35d577647cd7..c6138584f1ddeab3a4927774f44f9e78a8f08da7 100644 --- a/examples/dubbo/go-server/app/version.go +++ b/examples/dubbo/go-server/app/version.go @@ -1,5 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main var ( - Version string = "0.3.1" + Version = "2.6.0" ) diff --git a/examples/dubbo/go-server/assembly/common/build.sh b/examples/dubbo/go-server/assembly/common/build.sh index a41fbbac321b74849d71b28a65f8b7c5de13cf0f..15ac904f7c265d942d7018439719af7e7391aa41 100644 --- a/examples/dubbo/go-server/assembly/common/build.sh +++ b/examples/dubbo/go-server/assembly/common/build.sh @@ -15,7 +15,7 @@ PROJECT_HOME=`pwd` TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` if [[ ${GOOS} == "windows" ]]; then TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe fi diff --git a/examples/dubbo/go-server/profiles/dev/log.yml b/examples/dubbo/go-server/profiles/dev/log.yml index 427308d52b028d1740dac56b66b2e54fa76c6fe2..59fa4279ad85272c4c49d532beaf23b74d00f58a 100644 --- a/examples/dubbo/go-server/profiles/dev/log.yml +++ b/examples/dubbo/go-server/profiles/dev/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/dubbo/go-server/profiles/dev/server.yml b/examples/dubbo/go-server/profiles/dev/server.yml index 6477a6638540e757452c737173088b2af7fe3323..619f2ddca6a0164e222f4a08669beb79dc077914 100644 --- a/examples/dubbo/go-server/profiles/dev/server.yml +++ b/examples/dubbo/go-server/profiles/dev/server.yml @@ -10,43 +10,43 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" services: -- registries: - - "hangzhouzk" - - "shanghaizk" - protocol : "dubbo" - # 鐩稿綋浜巇ubbo.xml涓殑interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 + - registries: + - "hangzhouzk" + - "shanghaizk" + protocol : "dubbo" + # 鐩稿綋浜巇ubbo.xml涓殑interface + interface : "com.ikurento.user.UserProvider" loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -- name: "dubbo" - ip : "127.0.0.1" - port : 20000 -#- name: "jsonrpc" -# ip: "127.0.0.1" -# port: 20001 + - name: "dubbo" + # ip : "127.0.0.1" + port : 20000 + #- name: "jsonrpc" + # ip: "127.0.0.1" + # port: 20001 protocol_conf: dubbo: diff --git a/examples/dubbo/go-server/profiles/release/log.yml b/examples/dubbo/go-server/profiles/release/log.yml index b9139c2e9cb21d5f557eb53e5d6909fca64ac205..e0514be020eedf594d99d112183cdd5ce199e46d 100644 --- a/examples/dubbo/go-server/profiles/release/log.yml +++ b/examples/dubbo/go-server/profiles/release/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/dubbo/go-server/profiles/release/server.yml b/examples/dubbo/go-server/profiles/release/server.yml index 728e8802dd5d49aef4336597a6810724d0836c16..c4d98eb746d7c5418dce6d0dca2fe89da137d680 100644 --- a/examples/dubbo/go-server/profiles/release/server.yml +++ b/examples/dubbo/go-server/profiles/release/server.yml @@ -10,43 +10,43 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" services: -- registries: - - "hangzhouzk" - - "shanghaizk" - protocol : "dubbo" - # 鐩稿綋浜巇ubbo.xml涓殑interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 + - registries: + - "hangzhouzk" + - "shanghaizk" + protocol : "dubbo" + # 鐩稿綋浜巇ubbo.xml涓殑interface + interface : "com.ikurento.user.UserProvider" loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -- name: "dubbo" - ip : "127.0.0.1" - port : 20000 -#- name: "jsonrpc" -# ip: "127.0.0.1" -# port: 20001 + - name: "dubbo" + # ip : "127.0.0.1" + port : 20000 + #- name: "jsonrpc" + # ip: "127.0.0.1" + # port: 20001 protocol_conf: dubbo: diff --git a/examples/dubbo/go-server/profiles/test/log.yml b/examples/dubbo/go-server/profiles/test/log.yml index d2e1d05f3f46bc4ec6c7b8a16211c13d2189219d..baee0b7248484e425f88f35ab128212c931ff85e 100644 --- a/examples/dubbo/go-server/profiles/test/log.yml +++ b/examples/dubbo/go-server/profiles/test/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/dubbo/go-server/profiles/test/server.yml b/examples/dubbo/go-server/profiles/test/server.yml index 728e8802dd5d49aef4336597a6810724d0836c16..c4d98eb746d7c5418dce6d0dca2fe89da137d680 100644 --- a/examples/dubbo/go-server/profiles/test/server.yml +++ b/examples/dubbo/go-server/profiles/test/server.yml @@ -10,43 +10,43 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" services: -- registries: - - "hangzhouzk" - - "shanghaizk" - protocol : "dubbo" - # 鐩稿綋浜巇ubbo.xml涓殑interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 + - registries: + - "hangzhouzk" + - "shanghaizk" + protocol : "dubbo" + # 鐩稿綋浜巇ubbo.xml涓殑interface + interface : "com.ikurento.user.UserProvider" loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -- name: "dubbo" - ip : "127.0.0.1" - port : 20000 -#- name: "jsonrpc" -# ip: "127.0.0.1" -# port: 20001 + - name: "dubbo" + # ip : "127.0.0.1" + port : 20000 + #- name: "jsonrpc" + # ip: "127.0.0.1" + # port: 20001 protocol_conf: dubbo: diff --git a/examples/dubbo/java-client/pom.xml b/examples/dubbo/java-client/pom.xml index 414ca2bb963c8d8f17df35ad426b42506b944d22..c3e3464f2073220c765c2510aad124e0a80289e8 100755 --- a/examples/dubbo/java-client/pom.xml +++ b/examples/dubbo/java-client/pom.xml @@ -97,7 +97,7 @@ <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> - <version>1.4.1</version> + <version>1.4.7</version> </dependency> <dependency> <groupId>org.apache.bsf</groupId> @@ -107,7 +107,7 @@ <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> - <version>3.3.3</version> + <version>3.4.14</version> </dependency> <dependency> <groupId>com.github.sgroschupf</groupId> diff --git a/examples/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java b/examples/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java index b410813c74a7432cbbe1f2e7627faba9ebb17e70..f1100e79ac2ee31ea13b98af345d5472eb08488e 100644 --- a/examples/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java +++ b/examples/dubbo/java-client/src/main/java/com/ikurento/user/Consumer.java @@ -51,9 +51,18 @@ public class Consumer { System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] " + " UserInfo, Id:" + user2.getId() + ", name:" + user2.getName() + ", sex:" + user2.getSex().toString() + ", age:" + user2.getAge() + ", time:" + user2.getTime().toString()); + + User user9 = userProvider.GetUser1("A003"); } catch (Exception e) { + System.out.println("*************exception***********"); e.printStackTrace(); } + try { + userProvider.GetErr("A003"); + } catch (Throwable t) { + System.out.println("*************exception***********"); + t.printStackTrace(); + } } private void testGetUsers() throws Exception { diff --git a/examples/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java b/examples/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java index d5bce8105673a24d78ddd3a636788d1ccf8e57a6..036f46332105710ffcc53465b487ada860c25172 100644 --- a/examples/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/dubbo/java-client/src/main/java/com/ikurento/user/UserProvider.java @@ -20,6 +20,8 @@ import java.util.List; public interface UserProvider { User GetUser(String userId); + User GetErr(String userId) throws Exception; + User GetUser1(String userId); List<User> GetUsers(List<String> userIdList); User GetUser0(String userId, String name); diff --git a/examples/dubbo/java-server/pom.xml b/examples/dubbo/java-server/pom.xml index 12d00ebbcd58262afb00f249445fd9e7b68857ca..975157865e59f24693d755dd20b0aac4b179a793 100644 --- a/examples/dubbo/java-server/pom.xml +++ b/examples/dubbo/java-server/pom.xml @@ -74,12 +74,12 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> - <version>2.9.8</version> + <version>2.9.9</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.9.8</version> + <version>2.9.9</version> </dependency> <dependency> @@ -97,7 +97,7 @@ <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> - <version>3.4.6</version> + <version>3.4.14</version> </dependency> </dependencies> diff --git a/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java b/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java index b75740bbcd26a6438d22f7d3bf08fa5e316f7aa7..bb1d9a9d42444b1782d919c6a62ac2fc60e509b1 100644 --- a/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java +++ b/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProvider.java @@ -14,6 +14,8 @@ public interface UserProvider { User GetUser0(String userId, String name); + User GetErr(String userId) throws Exception; + Map<String, User> GetUserMap(List<String> userIdList); User getUser(int usercode); diff --git a/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java b/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java index f0d7faf3df40c3d422407ddf4d2f2c501e1efdf7..9eaf989a8204be5a7b0065b23dfec88eff837854 100644 --- a/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java +++ b/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderAnotherImpl.java @@ -35,7 +35,9 @@ public class UserProviderAnotherImpl implements UserProvider { public User GetUser0(String userId, String name) { return new User(userId, name, 48); } - + public User GetErr(String userId) throws Exception { + throw new Exception("exception"); + } public List<User> GetUsers(ArrayList<String> userIdList) { Iterator it = userIdList.iterator(); List<User> userList = new ArrayList<User>(); diff --git a/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java b/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java index 1311bd807d59d8336f4ada1296d3a05abd31a548..f8875651096ef719182eb0eeffb779de16425702 100644 --- a/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java +++ b/examples/dubbo/java-server/src/main/java/com/ikurento/user/UserProviderImpl.java @@ -32,6 +32,9 @@ public class UserProviderImpl implements UserProvider { public User GetUser(String userId) { return new User(userId, "zhangsan", 18); } + public User GetErr(String userId) throws Exception { + throw new Exception("exception"); + } public User GetUser0(String userId, String name) { return new User(userId, name, 18); } diff --git a/examples/jsonrpc/go-client/app/client.go b/examples/jsonrpc/go-client/app/client.go index b71f0efa20243ddf2635c56ee0eca7340db6ce03..30a4ed1692d650a2580c008dde6f834e2c29b81e 100644 --- a/examples/jsonrpc/go-client/app/client.go +++ b/examples/jsonrpc/go-client/app/client.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -24,20 +27,17 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" -) - -import ( - _ "github.com/dubbo/go-for-apache-dubbo/common/proxy/proxy_factory" - "github.com/dubbo/go-for-apache-dubbo/config" - _ "github.com/dubbo/go-for-apache-dubbo/protocol/jsonrpc" - _ "github.com/dubbo/go-for-apache-dubbo/registry/protocol" + "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/jsonrpc" + _ "github.com/apache/dubbo-go/registry/protocol" - _ "github.com/dubbo/go-for-apache-dubbo/filter/impl" + _ "github.com/apache/dubbo-go/filter/impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance" - _ "github.com/dubbo/go-for-apache-dubbo/registry/zookeeper" + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" ) var ( diff --git a/examples/jsonrpc/go-client/app/user.go b/examples/jsonrpc/go-client/app/user.go index 0d159876125a19bb9c75fbd21d893942763a67c8..6e2a97081ce74b28424e9faa8a74194cf9ea141f 100644 --- a/examples/jsonrpc/go-client/app/user.go +++ b/examples/jsonrpc/go-client/app/user.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -21,7 +24,7 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/config" + "github.com/apache/dubbo-go/config" ) func init() { diff --git a/examples/jsonrpc/go-client/app/version.go b/examples/jsonrpc/go-client/app/version.go index 33bb9cd02dd53fdbd84f9f96942cf2dc9c1ef115..c6138584f1ddeab3a4927774f44f9e78a8f08da7 100644 --- a/examples/jsonrpc/go-client/app/version.go +++ b/examples/jsonrpc/go-client/app/version.go @@ -1,5 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main var ( - Version = "0.3.1" + Version = "2.6.0" ) diff --git a/examples/jsonrpc/go-client/assembly/common/build.sh b/examples/jsonrpc/go-client/assembly/common/build.sh index 00763725b821e54dd0f378b0ec60757837067ef9..06b212db6c3dcc28e5e43666284662bcb7abcae4 100644 --- a/examples/jsonrpc/go-client/assembly/common/build.sh +++ b/examples/jsonrpc/go-client/assembly/common/build.sh @@ -15,7 +15,7 @@ PROJECT_HOME=`pwd` TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` if [[ ${GOOS} == "windows" ]]; then TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe fi diff --git a/examples/jsonrpc/go-client/profiles/dev/client.yml b/examples/jsonrpc/go-client/profiles/dev/client.yml index 50ed8d5011cbbd08b133f040eb0d71edb970f146..020adc5e6bd1294a8174f5c0e663f379fe03c88e 100644 --- a/examples/jsonrpc/go-client/profiles/dev/client.yml +++ b/examples/jsonrpc/go-client/profiles/dev/client.yml @@ -16,28 +16,52 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" + - registries : + - "hangzhouzk" + - "shanghaizk" - protocol : "jsonrpc" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + protocol : "jsonrpc" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 + +protocol_conf: + dubbo: + reconnect_interval: 0 + connection_number: 2 + heartbeat_period: "5s" + session_timeout: "20s" + fail_fast_timeout: "5s" + pool_size: 64 + pool_ttl: 600 + getty_session_param: + compress_encoding: false + tcp_no_delay: true + tcp_keep_alive: true + keep_alive_period: "120s" + tcp_r_buf_size: 262144 + tcp_w_buf_size: 65536 + pkg_rq_size: 1024 + pkg_wq_size: 512 + tcp_read_timeout: "1s" + tcp_write_timeout: "5s" + wait_timeout: "1s" + max_msg_len: 10240 + session_name: "client" diff --git a/examples/jsonrpc/go-client/profiles/dev/log.yml b/examples/jsonrpc/go-client/profiles/dev/log.yml index 427308d52b028d1740dac56b66b2e54fa76c6fe2..59fa4279ad85272c4c49d532beaf23b74d00f58a 100644 --- a/examples/jsonrpc/go-client/profiles/dev/log.yml +++ b/examples/jsonrpc/go-client/profiles/dev/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/jsonrpc/go-client/profiles/release/client.yml b/examples/jsonrpc/go-client/profiles/release/client.yml index 5aae8b717dc448162e0495e4b24d079f43351f4d..3e3bd63f5b2a73312936fc6dbc07404bcbe11687 100644 --- a/examples/jsonrpc/go-client/profiles/release/client.yml +++ b/examples/jsonrpc/go-client/profiles/release/client.yml @@ -17,28 +17,28 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" + - registries : + - "hangzhouzk" + - "shanghaizk" - protocol : "jsonrpc" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + protocol : "jsonrpc" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 diff --git a/examples/jsonrpc/go-client/profiles/release/log.yml b/examples/jsonrpc/go-client/profiles/release/log.yml index b9139c2e9cb21d5f557eb53e5d6909fca64ac205..e0514be020eedf594d99d112183cdd5ce199e46d 100644 --- a/examples/jsonrpc/go-client/profiles/release/log.yml +++ b/examples/jsonrpc/go-client/profiles/release/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/jsonrpc/go-client/profiles/test/client.yml b/examples/jsonrpc/go-client/profiles/test/client.yml index 5e0c0cea0a37672e9e24f5b0f9a7faeca9754f2a..e79f7f47f72f598775be0c226b2f63a3d334f8fe 100644 --- a/examples/jsonrpc/go-client/profiles/test/client.yml +++ b/examples/jsonrpc/go-client/profiles/test/client.yml @@ -16,28 +16,28 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" references: -- registries : - - "hangzhouzk" - - "shanghaizk" + - registries : + - "hangzhouzk" + - "shanghaizk" - protocol : "jsonrpc" - interface : "com.ikurento.user.UserProvider" - cluster: "failover" - methods : - - name: "GetUser" - retries: 3 + protocol : "jsonrpc" + interface : "com.ikurento.user.UserProvider" + cluster: "failover" + methods : + - name: "GetUser" + retries: 3 diff --git a/examples/jsonrpc/go-client/profiles/test/log.yml b/examples/jsonrpc/go-client/profiles/test/log.yml index d2e1d05f3f46bc4ec6c7b8a16211c13d2189219d..baee0b7248484e425f88f35ab128212c931ff85e 100644 --- a/examples/jsonrpc/go-client/profiles/test/log.yml +++ b/examples/jsonrpc/go-client/profiles/test/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/jsonrpc/go-server/app/server.go b/examples/jsonrpc/go-server/app/server.go index 90c78413c45b54aa883868b140290f22802ebd15..45692b4d1259ef0a8a8c4d784575488184289658 100644 --- a/examples/jsonrpc/go-server/app/server.go +++ b/examples/jsonrpc/go-server/app/server.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -23,17 +26,17 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" - _ "github.com/dubbo/go-for-apache-dubbo/common/proxy/proxy_factory" - "github.com/dubbo/go-for-apache-dubbo/config" - _ "github.com/dubbo/go-for-apache-dubbo/protocol/jsonrpc" - _ "github.com/dubbo/go-for-apache-dubbo/registry/protocol" + "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/protocol/jsonrpc" + _ "github.com/apache/dubbo-go/registry/protocol" - _ "github.com/dubbo/go-for-apache-dubbo/filter/impl" + _ "github.com/apache/dubbo-go/filter/impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - _ "github.com/dubbo/go-for-apache-dubbo/cluster/loadbalance" - _ "github.com/dubbo/go-for-apache-dubbo/registry/zookeeper" + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/registry/zookeeper" ) var ( diff --git a/examples/jsonrpc/go-server/app/user.go b/examples/jsonrpc/go-server/app/user.go index 9170de431a719351ee1e1af4e5c6bbcd4cbfde62..fbe6f3339c212d2bd42d52b6bbf7c7fcec6fb9c3 100644 --- a/examples/jsonrpc/go-server/app/user.go +++ b/examples/jsonrpc/go-server/app/user.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package main @@ -25,7 +28,7 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/config" + "github.com/apache/dubbo-go/config" ) type Gender int diff --git a/examples/jsonrpc/go-server/app/version.go b/examples/jsonrpc/go-server/app/version.go index c7552b26e11ec15fd51f3e18905d35d577647cd7..c6138584f1ddeab3a4927774f44f9e78a8f08da7 100644 --- a/examples/jsonrpc/go-server/app/version.go +++ b/examples/jsonrpc/go-server/app/version.go @@ -1,5 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main var ( - Version string = "0.3.1" + Version = "2.6.0" ) diff --git a/examples/jsonrpc/go-server/assembly/common/build.sh b/examples/jsonrpc/go-server/assembly/common/build.sh index a41fbbac321b74849d71b28a65f8b7c5de13cf0f..15ac904f7c265d942d7018439719af7e7391aa41 100644 --- a/examples/jsonrpc/go-server/assembly/common/build.sh +++ b/examples/jsonrpc/go-server/assembly/common/build.sh @@ -15,7 +15,7 @@ PROJECT_HOME=`pwd` TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` +version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` if [[ ${GOOS} == "windows" ]]; then TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe fi diff --git a/examples/jsonrpc/go-server/profiles/dev/log.yml b/examples/jsonrpc/go-server/profiles/dev/log.yml index 427308d52b028d1740dac56b66b2e54fa76c6fe2..59fa4279ad85272c4c49d532beaf23b74d00f58a 100644 --- a/examples/jsonrpc/go-server/profiles/dev/log.yml +++ b/examples/jsonrpc/go-server/profiles/dev/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/jsonrpc/go-server/profiles/dev/server.yml b/examples/jsonrpc/go-server/profiles/dev/server.yml index 945df75c1018280d70c9e78f48d86bc3dc3453ae..0175847a68c19427a35d000f6a7e6d215fd8cf64 100644 --- a/examples/jsonrpc/go-server/profiles/dev/server.yml +++ b/examples/jsonrpc/go-server/profiles/dev/server.yml @@ -10,41 +10,41 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" services: -- registries: - - "hangzhouzk" - - "shanghaizk" - protocol : "jsonrpc" - # 鐩稿綋浜巇ubbo.xml涓殑interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 - loadbalance: "random" + - registries: + - "hangzhouzk" + - "shanghaizk" + protocol : "jsonrpc" + # 鐩稿綋浜巇ubbo.xml涓殑interface + interface : "com.ikurento.user.UserProvider" + loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -#- name: "dubbo" -# ip : "127.0.0.1" -# port : 20000 -- name: "jsonrpc" - ip: "127.0.0.1" - port: 20001 + #- name: "dubbo" + # ip : "127.0.0.1" + # port : 20000 + - name: "jsonrpc" + ip: "127.0.0.1" + port: 20001 diff --git a/examples/jsonrpc/go-server/profiles/release/log.yml b/examples/jsonrpc/go-server/profiles/release/log.yml index b9139c2e9cb21d5f557eb53e5d6909fca64ac205..e0514be020eedf594d99d112183cdd5ce199e46d 100644 --- a/examples/jsonrpc/go-server/profiles/release/log.yml +++ b/examples/jsonrpc/go-server/profiles/release/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/jsonrpc/go-server/profiles/release/server.yml b/examples/jsonrpc/go-server/profiles/release/server.yml index 597c493d932a63497d265ac37d2d0715751d1005..3c70e82483be227d60e7e9806ed19d3f371ded11 100644 --- a/examples/jsonrpc/go-server/profiles/release/server.yml +++ b/examples/jsonrpc/go-server/profiles/release/server.yml @@ -26,25 +26,25 @@ registries : services: -- registries: - - "hangzhouzk" - - "shanghaizk" - protocol : "jsonrpc" - # 鐩稿綋浜巇ubbo.xml涓殑interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 + - registries: + - "hangzhouzk" + - "shanghaizk" + protocol : "jsonrpc" + # 鐩稿綋浜巇ubbo.xml涓殑interface + interface : "com.ikurento.user.UserProvider" loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -#- name: "dubbo" -# ip : "127.0.0.1" -# port : 20000 -- name: "jsonrpc" - ip: "127.0.0.1" - port: 20001 + #- name: "dubbo" + # ip : "127.0.0.1" + # port : 20000 + - name: "jsonrpc" + ip: "127.0.0.1" + port: 20001 diff --git a/examples/jsonrpc/go-server/profiles/test/log.yml b/examples/jsonrpc/go-server/profiles/test/log.yml index d2e1d05f3f46bc4ec6c7b8a16211c13d2189219d..baee0b7248484e425f88f35ab128212c931ff85e 100644 --- a/examples/jsonrpc/go-server/profiles/test/log.yml +++ b/examples/jsonrpc/go-server/profiles/test/log.yml @@ -22,7 +22,7 @@ encoderConfig: nameEncoder: "" outputPaths: -- "stderr" + - "stderr" errorOutputPaths: -- "stderr" + - "stderr" initialFields: diff --git a/examples/jsonrpc/go-server/profiles/test/server.yml b/examples/jsonrpc/go-server/profiles/test/server.yml index 597c493d932a63497d265ac37d2d0715751d1005..a8ad5746b35804cc0154830fa2d59be249bbc46b 100644 --- a/examples/jsonrpc/go-server/profiles/test/server.yml +++ b/examples/jsonrpc/go-server/profiles/test/server.yml @@ -10,41 +10,39 @@ application_config: environment : "dev" registries : -- id: "hangzhouzk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2181" - username: "" - password: "" - -- id: "shanghaizk" - type: "zookeeper" - timeout : "3s" - address: "127.0.0.1:2182" - username: "" - password: "" + - id: "hangzhouzk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2181" + username: "" + password: "" + - id: "shanghaizk" + type: "zookeeper" + timeout : "3s" + address: "127.0.0.1:2182" + username: "" + password: "" services: -- registries: - - "hangzhouzk" - - "shanghaizk" - protocol : "jsonrpc" - # 鐩稿綋浜巇ubbo.xml涓殑interface - interface : "com.ikurento.user.UserProvider" - loadbalance: "random" - warmup: "100" - cluster: "failover" - methods: - - name: "GetUser" - retries: 1 + - registries: + - "hangzhouzk" + - "shanghaizk" + protocol : "jsonrpc" + # 鐩稿綋浜巇ubbo.xml涓殑interface + interface : "com.ikurento.user.UserProvider" loadbalance: "random" + warmup: "100" + cluster: "failover" + methods: + - name: "GetUser" + retries: 1 + loadbalance: "random" protocols: -#- name: "dubbo" -# ip : "127.0.0.1" -# port : 20000 -- name: "jsonrpc" - ip: "127.0.0.1" - port: 20001 - + #- name: "dubbo" + # ip : "127.0.0.1" + # port : 20000 + - name: "jsonrpc" + ip: "127.0.0.1" + port: 20001 diff --git a/examples/jsonrpc/java-client/pom.xml b/examples/jsonrpc/java-client/pom.xml index bc6d2b7ff022d5de0a473962adf5ed82628f20a3..79a8a7e11b3c00fa151aa2dc728320a874304bff 100644 --- a/examples/jsonrpc/java-client/pom.xml +++ b/examples/jsonrpc/java-client/pom.xml @@ -97,7 +97,7 @@ <dependency> <groupId>com.thoughtworks.xstream</groupId> <artifactId>xstream</artifactId> - <version>1.4.1</version> + <version>1.4.7</version> </dependency> <dependency> <groupId>org.apache.bsf</groupId> @@ -107,7 +107,7 @@ <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> - <version>3.3.3</version> + <version>3.4.14</version> </dependency> <dependency> <groupId>com.github.sgroschupf</groupId> diff --git a/examples/jsonrpc/java-server/pom.xml b/examples/jsonrpc/java-server/pom.xml index 12d00ebbcd58262afb00f249445fd9e7b68857ca..975157865e59f24693d755dd20b0aac4b179a793 100644 --- a/examples/jsonrpc/java-server/pom.xml +++ b/examples/jsonrpc/java-server/pom.xml @@ -74,12 +74,12 @@ <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> - <version>2.9.8</version> + <version>2.9.9</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.9.8</version> + <version>2.9.9</version> </dependency> <dependency> @@ -97,7 +97,7 @@ <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> - <version>3.4.6</version> + <version>3.4.14</version> </dependency> </dependencies> diff --git a/filter/filter.go b/filter/filter.go index 384dbf1a5771ed5ddac2b4863d317616421d45f9..5bd78998a76a1b0e8af99b0b3f0d7e6c103bb794 100644 --- a/filter/filter.go +++ b/filter/filter.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package filter import ( - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/protocol" ) // Extension - Filter diff --git a/filter/impl/echo_filter.go b/filter/impl/echo_filter.go index 22ac6abeef6981c50fcec46ca55a7e6edf47bc08..5eb5a37fa500bd8c180d879240d1c1e367df31ce 100644 --- a/filter/impl/echo_filter.go +++ b/filter/impl/echo_filter.go @@ -1,32 +1,34 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package impl import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/filter" + "github.com/apache/dubbo-go/protocol" ) -import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/filter" - "github.com/dubbo/go-for-apache-dubbo/protocol" +const ( + ECHO = "echo" ) -const ECHO = "echo" - func init() { extension.SetFilter(ECHO, GetFilter) } @@ -34,8 +36,7 @@ func init() { // RPCService need a Echo method in consumer, if you want to use EchoFilter // eg: // Echo func(ctx context.Context, arg interface{}, rsp *Xxx) error -type EchoFilter struct { -} +type EchoFilter struct{} func (ef *EchoFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invocation) protocol.Result { logger.Infof("invoking echo filter.") @@ -45,6 +46,7 @@ func (ef *EchoFilter) Invoke(invoker protocol.Invoker, invocation protocol.Invoc Rest: invocation.Arguments()[0], } } + return invoker.Invoke(invocation) } diff --git a/filter/impl/echo_filter_test.go b/filter/impl/echo_filter_test.go index f8774edb8960df9f26e1b41608f408618f4cc343..e2752c85b24b5dbc8175cbd125ed771b412d1818 100644 --- a/filter/impl/echo_filter_test.go +++ b/filter/impl/echo_filter_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package impl @@ -23,9 +26,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) func TestEchoFilter_Invoke(t *testing.T) { diff --git a/go.mod b/go.mod index b03fcd5e5850d0b292089d2c7cbe89dcd943bbef..4c2276429ae315a44c282a8af9fb7e6d7ee1be8e 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,8 @@ -module github.com/dubbo/go-for-apache-dubbo +module github.com/apache/dubbo-go require ( - github.com/dubbogo/getty v0.0.0-20190523180329-bdf5e640ea53 - github.com/dubbogo/hessian2 v0.0.0-20190525165532-d994415a90c3 + github.com/dubbogo/getty v1.0.7 + github.com/dubbogo/hessian2 v1.0.1 github.com/pkg/errors v0.8.1 github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec github.com/stretchr/testify v1.3.0 diff --git a/go.sum b/go.sum index 0a1a01f0f9b67a0bec600f54bd138f0ef84d86db..a4fd7f5099b5521b03e03cf5958c641991433d39 100644 --- a/go.sum +++ b/go.sum @@ -1,140 +1,35 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/AlexStocks/getty v0.0.0-20190331201845-1ca64ac5a589/go.mod h1:n25mdqPgFi06sWL6mZTjm1hBIZuKwgXUVXAX+KGB97U= -github.com/AlexStocks/goext v0.3.2/go.mod h1:3M5j9Pjge4CdkNg2WIjRLUeoPedJHHKwkkglDGSl3Hc= -github.com/AlexStocks/log4go v1.0.2/go.mod h1:6kCCRo/orDo8mh5CEDOeuSSM674wBQ8M6E0K8dVOIz4= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= -github.com/coreos/etcd v3.3.12+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd v0.0.0-20190318101727-c7c1946145b6/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dubbogo/getty v0.0.0-20190523180329-bdf5e640ea53 h1:bniSNoC4xnAbrx4estwc9F0qkWnh6ZDsAS0y9d7mPos= -github.com/dubbogo/getty v0.0.0-20190523180329-bdf5e640ea53/go.mod h1:cRMSuoCmwc5lULFFnYZTxyCfZhObmRTNbS7XRnPNHSo= -github.com/dubbogo/hessian2 v0.0.0-20190410112310-f093e4436e31/go.mod h1:v+gfInE8fm/k3Fjkb2oUCKSO9LKbWvf+PtweEI89BmI= -github.com/dubbogo/hessian2 v0.0.0-20190525165532-d994415a90c3 h1:qK0t4cWXFAng5VoPRdvnUyRyB9TdE+Q7G3ROOEY86tE= -github.com/dubbogo/hessian2 v0.0.0-20190525165532-d994415a90c3/go.mod h1:XFGDn4oSZX26zkcfhkM/fCJrOqwQJxk/xgWW1KMJBKM= -github.com/fatih/set v0.2.1/go.mod h1:+RKtMCH+favT2+3YecHGxcc0b4KyVWA1QWWJUs4E0CI= -github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/dubbogo/getty v1.0.7 h1:5Hg+JwXyCKm9Yr4yJkm98ahhnoa8c2h6br5QJxwQ+YU= +github.com/dubbogo/getty v1.0.7/go.mod h1:cRMSuoCmwc5lULFFnYZTxyCfZhObmRTNbS7XRnPNHSo= +github.com/dubbogo/hessian2 v1.0.1 h1:ztI7gJxR3Isxrrl2jE1IZKX61eNR93eRKGhn49vPEX8= +github.com/dubbogo/hessian2 v1.0.1/go.mod h1:XFGDn4oSZX26zkcfhkM/fCJrOqwQJxk/xgWW1KMJBKM= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= -github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/juju/clock v0.0.0-20190205081909-9c5c9712527c/go.mod h1:nD0vlnrUjcjJhqN5WuCWZyzfd5AHZAC9/ajvbSx69xA= -github.com/juju/errors v0.0.0-20190207033735-e65537c515d7/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= -github.com/juju/loggo v0.0.0-20190212223446-d976af380377/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= -github.com/juju/retry v0.0.0-20180821225755-9058e192b216/go.mod h1:OohPQGsr4pnxwD5YljhQ+TZnuVRYpa5irjugL1Yuif4= -github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= -github.com/juju/utils v0.0.0-20180820210520-bf9cc5bdd62d/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= -github.com/juju/version v0.0.0-20180108022336-b64dbd566305/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= -github.com/k0kubun/pp v3.0.0+incompatible/go.mod h1:GWse8YhT0p8pT4ir3ZgBbfZild3tgzSScAn6HmfYukg= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/name5566/leaf v0.0.0-20181103040206-1364c176dfbd/go.mod h1:JrOIxq3vDxvtuEI7Kmm2yqkuBfuT9DMLFMnCyYHLaKM= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec h1:6ncX5ko6B9LntYM0YBRXkiSaZMmLYeZ/NWcmeB43mMY= github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec h1:6ncX5ko6B9LntYM0YBRXkiSaZMmLYeZ/NWcmeB43mMY= github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/samuel/go-zookeeper v0.0.0-20180130194729-c4fab1ac1bec/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= -github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/ugorji/go v1.1.2/go.mod h1:hnLbHMwcvSihnDhEfx2/BzKp2xb0Y+ErdfYcrs9tkJQ= -github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780/go.mod h1:iT03XoTwV7xq/+UGwKO3UbC1nNNlopQiY61beSdrtOA= -github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53 h1:kcXqo9vE6fsZY5X5Rd7R1l7fTgnWaDCVmln65REefiE= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= -gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= -gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/protocol/dubbo/client.go b/protocol/dubbo/client.go index ff094eb5aaa1af8d2ffa6a6c210574303e9052f2..d22ac91ed562468a40daf693948d79962bf07e0d 100644 --- a/protocol/dubbo/client.go +++ b/protocol/dubbo/client.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -29,10 +32,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/config" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/config" ) var ( @@ -198,6 +201,13 @@ func (c *Client) AsyncCall(addr string, svcUrl common.URL, method string, args i return perrors.WithStack(c.call(CT_TwoWay, addr, svcUrl, method, args, reply, callback, copts)) } +func (c *Client) GetPendingResponse(seq SequenceType) *PendingResponse { + c.pendingLock.RLock() + defer c.pendingLock.RUnlock() + + return c.pendingResponses[SequenceType(seq)] +} + func (c *Client) call(ct CallType, addr string, svcUrl common.URL, method string, args, reply interface{}, callback AsyncCallback, opts CallOptions) error { @@ -254,7 +264,7 @@ func (c *Client) call(ct CallType, addr string, svcUrl common.URL, method string } select { - case <-getty.GetTimeWheel().After(opts.ResponseTimeout): + case <-time.After(opts.ResponseTimeout): err = errClientReadTimeout c.removePendingResponse(SequenceType(rsp.seq)) case <-rsp.done: diff --git a/protocol/dubbo/client_test.go b/protocol/dubbo/client_test.go index 216d2e10dd2fafb5decb08856ea2258b661004c7..14982c6f123101ea9581542790c74bfc999437b5 100644 --- a/protocol/dubbo/client_test.go +++ b/protocol/dubbo/client_test.go @@ -1,35 +1,39 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo import ( + "bytes" "context" - "github.com/dubbogo/hessian2" "sync" "testing" "time" ) import ( + "github.com/dubbogo/hessian2" perrors "github.com/pkg/errors" "github.com/stretchr/testify/assert" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) type ( @@ -70,7 +74,13 @@ func TestClient_Call(t *testing.T) { c.pool = newGettyRPCClientConnPool(c, clientConf.PoolSize, time.Duration(int(time.Second)*clientConf.PoolTTL)) user := &User{} - err := c.Call("127.0.0.1:20000", url, "GetUser", []interface{}{"1", "username"}, user) + err := c.Call("127.0.0.1:20000", url, "GetBigPkg", []interface{}{}, user) + assert.NoError(t, err) + assert.NotEqual(t, "", user.Id) + assert.NotEqual(t, "", user.Name) + + user = &User{} + err = c.Call("127.0.0.1:20000", url, "GetUser", []interface{}{"1", "username"}, user) assert.NoError(t, err) assert.Equal(t, User{Id: "1", Name: "username"}, *user) @@ -81,7 +91,7 @@ func TestClient_Call(t *testing.T) { user = &User{} err = c.Call("127.0.0.1:20000", url, "GetUser1", []interface{}{"1", "username"}, user) - assert.EqualError(t, err, "java exception:error") + assert.EqualError(t, err, "got exception: error") user2 := []interface{}{} err = c.Call("127.0.0.1:20000", url, "GetUser2", []interface{}{"1", "username"}, &user2) @@ -134,7 +144,7 @@ func InitTest(t *testing.T) (protocol.Protocol, common.URL) { methods, err := common.ServiceMap.Register("dubbo", &UserProvider{}) assert.NoError(t, err) - assert.Equal(t, "GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) + assert.Equal(t, "GetBigPkg,GetUser,GetUser0,GetUser1,GetUser2,GetUser3,GetUser4", methods) // config SetClientConf(ClientConfig{ @@ -153,10 +163,10 @@ func InitTest(t *testing.T) (protocol.Protocol, common.URL) { TcpWBufSize: 65536, PkgRQSize: 1024, PkgWQSize: 512, - TcpReadTimeout: "1s", + TcpReadTimeout: "4s", TcpWriteTimeout: "5s", WaitTimeout: "1s", - MaxMsgLen: 1024, + MaxMsgLen: 10240000000, SessionName: "client", }, }) @@ -177,7 +187,7 @@ func InitTest(t *testing.T) (protocol.Protocol, common.URL) { TcpReadTimeout: "1s", TcpWriteTimeout: "5s", WaitTimeout: "1s", - MaxMsgLen: 1024, + MaxMsgLen: 10240000000, SessionName: "server", }}) assert.NoError(t, srvConf.CheckValidity()) @@ -197,6 +207,18 @@ func InitTest(t *testing.T) (protocol.Protocol, common.URL) { return proto, url } +// size:4801228 +func (u *UserProvider) GetBigPkg(ctx context.Context, req []interface{}, rsp *User) error { + argBuf := new(bytes.Buffer) + for i := 0; i < 4000; i++ { + argBuf.WriteString("鍑婚紦鍏堕晽锛岃笂璺冪敤鍏点€傚湡鍥藉煄婕曪紝鎴戠嫭鍗楄銆備粠瀛欏瓙浠诧紝骞抽檲涓庡畫銆備笉鎴戜互褰掞紝蹇у績鏈夊俊銆傜埌灞呯埌澶勶紵鐖颁抚鍏堕┈锛熶簬浠ユ眰涔嬶紵浜庢灄涔嬩笅銆傛鐢熷闃旓紝涓庡瓙鎴愯銆傛墽瀛愪箣鎵嬶紝涓庡瓙鍋曡€併€備簬鍡熼様鍏紝涓嶆垜娲诲叜銆備簬鍡熸吹鍏紝涓嶆垜淇″叜銆�") + argBuf.WriteString("鍑婚紦鍏堕晽锛岃笂璺冪敤鍏点€傚湡鍥藉煄婕曪紝鎴戠嫭鍗楄銆備粠瀛欏瓙浠诧紝骞抽檲涓庡畫銆備笉鎴戜互褰掞紝蹇у績鏈夊俊銆傜埌灞呯埌澶勶紵鐖颁抚鍏堕┈锛熶簬浠ユ眰涔嬶紵浜庢灄涔嬩笅銆傛鐢熷闃旓紝涓庡瓙鎴愯銆傛墽瀛愪箣鎵嬶紝涓庡瓙鍋曡€併€備簬鍡熼様鍏紝涓嶆垜娲诲叜銆備簬鍡熸吹鍏紝涓嶆垜淇″叜銆�") + } + rsp.Id = argBuf.String() + rsp.Name = argBuf.String() + return nil +} + func (u *UserProvider) GetUser(ctx context.Context, req []interface{}, rsp *User) error { rsp.Id = req[0].(string) rsp.Name = req[1].(string) diff --git a/protocol/dubbo/codec.go b/protocol/dubbo/codec.go index ba4d01ab0fbe49745cfd23646596cebaa2ae619e..9551c2b0b7b742228ae69701a9d86975d2c85e52 100644 --- a/protocol/dubbo/codec.go +++ b/protocol/dubbo/codec.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -71,7 +74,7 @@ func (p *DubboPackage) Marshal() (*bytes.Buffer, error) { } func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error { - codec := hessian.NewHessianCodec(bufio.NewReader(buf)) + codec := hessian.NewHessianCodec(bufio.NewReaderSize(buf, buf.Len())) // read header err := codec.ReadHeader(&p.Header) @@ -80,22 +83,19 @@ func (p *DubboPackage) Unmarshal(buf *bytes.Buffer, opts ...interface{}) error { } if len(opts) != 0 { // for client - if client, ok := opts[0].(*Client); ok { + client, ok := opts[0].(*Client) + if !ok { + return perrors.Errorf("opts[0] is not of type *Client") + } - r := client.pendingResponses[SequenceType(p.Header.ID)] - if r == nil { - return perrors.Errorf("pendingResponses[%v] = nil", p.Header.ID) - } - p.Body = client.pendingResponses[SequenceType(p.Header.ID)].reply + pendingRsp := client.GetPendingResponse(SequenceType(p.Header.ID)) + if pendingRsp == nil { + return perrors.Errorf("client.GetPendingResponse(%v) = nil", p.Header.ID) } else { - return perrors.Errorf("opts[0] is not *Client") + p.Body = &hessian.Response{RspObj: pendingRsp.reply} } } - if p.Header.Type&hessian.PackageHeartbeat != 0x00 { - return nil - } - // read body err = codec.ReadBody(p.Body) return perrors.WithStack(err) diff --git a/protocol/dubbo/codec_test.go b/protocol/dubbo/codec_test.go index 7ae227379afb79056b70564d1f3204d0606b1625..f585666b3769d1384681039d25cea98a36a589fc 100644 --- a/protocol/dubbo/codec_test.go +++ b/protocol/dubbo/codec_test.go @@ -1,27 +1,29 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo import ( "testing" "time" -) -import ( - "github.com/dubbogo/hessian2" "github.com/stretchr/testify/assert" + + hessian "github.com/dubbogo/hessian2" ) func TestDubboPackage_MarshalAndUnmarshal(t *testing.T) { diff --git a/protocol/dubbo/config.go b/protocol/dubbo/config.go index fa47118db82f5418d4d5f6703e212d82efebe83a..0af1a4a41116fca06d6793fddaf7f69ade2f30c0 100644 --- a/protocol/dubbo/config.go +++ b/protocol/dubbo/config.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo diff --git a/protocol/dubbo/dubbo_exporter.go b/protocol/dubbo/dubbo_exporter.go index d76ee812f1f21a29d391e404b2d68517f40bd4bc..bdec8a349f358f265fe064ed2083433f27d40a3b 100644 --- a/protocol/dubbo/dubbo_exporter.go +++ b/protocol/dubbo/dubbo_exporter.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -19,10 +22,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" ) type DubboExporter struct { diff --git a/protocol/dubbo/dubbo_invoker.go b/protocol/dubbo/dubbo_invoker.go index 690e4d9b9a476eb832adcedd41f7ddb5ba52939f..46b3dcc8463d8406c494d80149b28f0dba7444d0 100644 --- a/protocol/dubbo/dubbo_invoker.go +++ b/protocol/dubbo/dubbo_invoker.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -24,11 +27,11 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" - invocation_impl "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + invocation_impl "github.com/apache/dubbo-go/protocol/invocation" ) var Err_No_Reply = perrors.New("request need @reply") diff --git a/protocol/dubbo/dubbo_invoker_test.go b/protocol/dubbo/dubbo_invoker_test.go index 3931279ef5dff9a9ffd450a114a63dbcab223611..4368bb4630900eb2c4eece760b3b3e5c4887c478 100644 --- a/protocol/dubbo/dubbo_invoker_test.go +++ b/protocol/dubbo/dubbo_invoker_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -25,8 +28,8 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol/invocation" ) func TestDubboInvoker_Invoke(t *testing.T) { diff --git a/protocol/dubbo/dubbo_protocol.go b/protocol/dubbo/dubbo_protocol.go index 512ca099dd8138261e7b50e5cfc07abec273e2d3..269a38cf6f9e5891bf622aa6a63820ebc5989194 100644 --- a/protocol/dubbo/dubbo_protocol.go +++ b/protocol/dubbo/dubbo_protocol.go @@ -1,33 +1,40 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" ) -const DUBBO = "dubbo" +const ( + DUBBO = "dubbo" +) func init() { extension.SetProtocol(DUBBO, GetProtocol) } -var dubboProtocol *DubboProtocol +var ( + dubboProtocol *DubboProtocol +) type DubboProtocol struct { protocol.BaseProtocol diff --git a/protocol/dubbo/dubbo_protocol_test.go b/protocol/dubbo/dubbo_protocol_test.go index 9c89667923214248e940b3f98a602a8d4a3e66af..0c4bfdcc7a7089873b66f278028f2e4358b013d3 100644 --- a/protocol/dubbo/dubbo_protocol_test.go +++ b/protocol/dubbo/dubbo_protocol_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -24,8 +27,8 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) func TestDubboProtocol_Export(t *testing.T) { diff --git a/protocol/dubbo/listener.go b/protocol/dubbo/listener.go index fc56050c12a196753aac606dbbc8a801e7e79040..ea8c38db9817ae2df078ef9b21caaf7b13751b3e 100644 --- a/protocol/dubbo/listener.go +++ b/protocol/dubbo/listener.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -28,11 +31,11 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) // todo: WritePkg_Timeout will entry *.yml @@ -83,6 +86,9 @@ func (h *RpcClientHandler) OnMessage(session getty.Session, pkg interface{}) { if p.Header.Type&hessian.PackageHeartbeat != 0x00 { logger.Debugf("get rpc heartbeat response{header: %#v, body: %#v}", p.Header, p.Body) + if p.Err != nil { + logger.Errorf("rpc heartbeat response{error: %#v}", p.Err) + } return } logger.Debugf("get rpc response{header: %#v, body: %#v}", p.Header, p.Body) @@ -200,7 +206,6 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) { // not twoway if p.Header.Type&hessian.PackageRequest_TwoWay == 0x00 { twoway = false - h.reply(session, p, hessian.PackageResponse) } invoker := h.exporter.GetInvoker() @@ -212,7 +217,7 @@ func (h *RpcServerHandler) OnMessage(session getty.Session, pkg interface{}) { constant.VERSION_KEY: p.Service.Version, })) if err := result.Error(); err != nil { - p.Header.ResponseStatus = hessian.Response_SERVER_ERROR + p.Header.ResponseStatus = hessian.Response_OK p.Body = err h.reply(session, p, hessian.PackageResponse) return @@ -261,15 +266,15 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) { defer func() { if e := recover(); e != nil { - req.Header.ResponseStatus = hessian.Response_BAD_REQUEST + req.Header.ResponseStatus = hessian.Response_SERVER_ERROR if err, ok := e.(error); ok { logger.Errorf("callService panic: %#v", err) - req.Body = e.(error) + req.Body = perrors.WithStack(err) } else if err, ok := e.(string); ok { logger.Errorf("callService panic: %#v", perrors.New(err)) req.Body = perrors.New(err) } else { - logger.Errorf("callService panic: %#v", e) + logger.Errorf("callService panic: %#v, this is impossible.", e) req.Body = e } } @@ -278,7 +283,7 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) { svcIf := req.Body.(map[string]interface{})["service"] if svcIf == nil { logger.Errorf("service not found!") - req.Header.ResponseStatus = hessian.Response_SERVICE_NOT_FOUND + req.Header.ResponseStatus = hessian.Response_BAD_REQUEST req.Body = perrors.New("service not found") return } @@ -286,7 +291,7 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) { method := svc.Method()[req.Service.Method] if method == nil { logger.Errorf("method not found!") - req.Header.ResponseStatus = hessian.Response_SERVICE_NOT_FOUND + req.Header.ResponseStatus = hessian.Response_BAD_REQUEST req.Body = perrors.New("method not found") return } @@ -323,8 +328,8 @@ func (h *RpcServerHandler) callService(req *DubboPackage, ctx context.Context) { retErr = returnValues[1].Interface() } if retErr != nil { - req.Header.ResponseStatus = hessian.Response_SERVER_ERROR - req.Body = retErr.(error) + req.Header.ResponseStatus = hessian.Response_OK + req.Body = retErr } else { req.Body = replyv.Interface() } diff --git a/protocol/dubbo/pool.go b/protocol/dubbo/pool.go index 60a65e45fe386a027c6e1556949730cf9ef050f4..0ab43ede7f1bbee8b7d952ae2e4a210e9850b80a 100644 --- a/protocol/dubbo/pool.go +++ b/protocol/dubbo/pool.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -29,14 +32,14 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common/logger" ) type gettyRPCClient struct { once sync.Once protocol string addr string - created int64 // 涓�0锛屽垯璇存槑娌℃湁琚垱寤烘垨鑰呰閿€姣佷簡 + created int64 // zero, not create or be destroyed pool *gettyRPCClientPool diff --git a/protocol/dubbo/readwriter.go b/protocol/dubbo/readwriter.go index 87b73aed91d5232975b6f6b1513e3d728c0f2175..6d789ae13e458249747f660c406ab2fe4c6463f0 100644 --- a/protocol/dubbo/readwriter.go +++ b/protocol/dubbo/readwriter.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -21,12 +24,13 @@ import ( import ( "github.com/dubbogo/getty" + "github.com/dubbogo/hessian2" perrors "github.com/pkg/errors" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" ) //////////////////////////////////////////// @@ -49,11 +53,20 @@ func (p *RpcClientPackageHandler) Read(ss getty.Session, data []byte) (interface buf := bytes.NewBuffer(data) err := pkg.Unmarshal(buf, p.client) if err != nil { - pkg.Err = perrors.WithStack(err) // client will get this err - return pkg, len(data), nil + originErr := perrors.Cause(err) + if originErr == hessian.ErrHeaderNotEnough || originErr == hessian.ErrBodyNotEnough { + return nil, 0, nil + } + + logger.Errorf("pkg.Unmarshal(ss:%+v, len(@data):%d) = error:%+v", ss, len(data), err) + + return nil, 0, perrors.WithStack(err) } - return pkg, len(data), nil + pkg.Err = pkg.Body.(*hessian.Response).Exception + pkg.Body = pkg.Body.(*hessian.Response).RspObj + + return pkg, hessian.HEADER_LENGTH + pkg.Header.BodyLen, nil } func (p *RpcClientPackageHandler) Write(ss getty.Session, pkg interface{}) error { @@ -91,46 +104,56 @@ func (p *RpcServerPackageHandler) Read(ss getty.Session, data []byte) (interface buf := bytes.NewBuffer(data) err := pkg.Unmarshal(buf) if err != nil { + originErr := perrors.Cause(err) + if originErr == hessian.ErrHeaderNotEnough || originErr == hessian.ErrBodyNotEnough { + return nil, 0, nil + } + + logger.Errorf("pkg.Unmarshal(ss:%+v, len(@data):%d) = error:%+v", ss, len(data), err) + return nil, 0, perrors.WithStack(err) } - // convert params of request - req := pkg.Body.([]interface{}) // length of body should be 7 - if len(req) > 0 { - var dubboVersion, argsTypes string - var args []interface{} - var attachments map[interface{}]interface{} - if req[0] != nil { - dubboVersion = req[0].(string) - } - if req[1] != nil { - pkg.Service.Path = req[1].(string) - } - if req[2] != nil { - pkg.Service.Version = req[2].(string) - } - if req[3] != nil { - pkg.Service.Method = req[3].(string) - } - if req[4] != nil { - argsTypes = req[4].(string) - } - if req[5] != nil { - args = req[5].([]interface{}) - } - if req[6] != nil { - attachments = req[6].(map[interface{}]interface{}) - } - pkg.Service.Interface = attachments[constant.INTERFACE_KEY].(string) - pkg.Body = map[string]interface{}{ - "dubboVersion": dubboVersion, - "argsTypes": argsTypes, - "args": args, - "service": common.ServiceMap.GetService(DUBBO, pkg.Service.Interface), - "attachments": attachments, + + if pkg.Header.Type&hessian.PackageHeartbeat == 0x00 { + // convert params of request + req := pkg.Body.([]interface{}) // length of body should be 7 + if len(req) > 0 { + var dubboVersion, argsTypes string + var args []interface{} + var attachments map[interface{}]interface{} + if req[0] != nil { + dubboVersion = req[0].(string) + } + if req[1] != nil { + pkg.Service.Path = req[1].(string) + } + if req[2] != nil { + pkg.Service.Version = req[2].(string) + } + if req[3] != nil { + pkg.Service.Method = req[3].(string) + } + if req[4] != nil { + argsTypes = req[4].(string) + } + if req[5] != nil { + args = req[5].([]interface{}) + } + if req[6] != nil { + attachments = req[6].(map[interface{}]interface{}) + } + pkg.Service.Interface = attachments[constant.INTERFACE_KEY].(string) + pkg.Body = map[string]interface{}{ + "dubboVersion": dubboVersion, + "argsTypes": argsTypes, + "args": args, + "service": common.ServiceMap.GetService(DUBBO, pkg.Service.Interface), + "attachments": attachments, + } } } - return pkg, len(data), nil + return pkg, hessian.HEADER_LENGTH + pkg.Header.BodyLen, nil } func (p *RpcServerPackageHandler) Write(ss getty.Session, pkg interface{}) error { diff --git a/protocol/dubbo/server.go b/protocol/dubbo/server.go index f8de070bcc42bf0f81ad2a2e12658f2283bdf210..80568c61bb44b540df0d0689273f22d206411ca4 100644 --- a/protocol/dubbo/server.go +++ b/protocol/dubbo/server.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package dubbo @@ -25,10 +28,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/config" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/protocol" ) var srvConf *ServerConfig diff --git a/protocol/invocation.go b/protocol/invocation.go index 0297a556c4708292d7d5706718af596804d788f4..055e7a4cd18707772d6ba75303053f15dc55dbe3 100644 --- a/protocol/invocation.go +++ b/protocol/invocation.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocol diff --git a/protocol/invocation/rpcinvocation.go b/protocol/invocation/rpcinvocation.go index 87ab0c67838ba028eab81185eb6d4ccae5679966..c8f45c561ef88f49d33b755f988ff9a125e30c8f 100644 --- a/protocol/invocation/rpcinvocation.go +++ b/protocol/invocation/rpcinvocation.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package invocation @@ -19,9 +22,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol" ) ///////////////////////////// diff --git a/protocol/invoker.go b/protocol/invoker.go index bedbb10442031fe8b723286f824c03f321623ca1..fe6aab848caceed50fc3db3e657ce87c45eac2ed 100644 --- a/protocol/invoker.go +++ b/protocol/invoker.go @@ -1,22 +1,25 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocol import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" ) // Extension - Invoker diff --git a/protocol/jsonrpc/http.go b/protocol/jsonrpc/http.go index 60257ce027c1434bfd5cc06249f380d3511957dd..af65db04b880a0e6d7f18fd5a96b775795be0fab 100644 --- a/protocol/jsonrpc/http.go +++ b/protocol/jsonrpc/http.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -34,8 +37,8 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" ) ////////////////////////////////////////////// diff --git a/protocol/jsonrpc/http_test.go b/protocol/jsonrpc/http_test.go index 55f86f454e89bc16f409abfa141508207b749279..3f6f983702360b9c3036c943b0651e5c935376e3 100644 --- a/protocol/jsonrpc/http_test.go +++ b/protocol/jsonrpc/http_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -27,9 +30,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/protocol" ) type ( diff --git a/protocol/jsonrpc/json.go b/protocol/jsonrpc/json.go index c5c26d3f93172f563bb89642ef0664c904c3e4e8..c147f9add85041b3dfaf1c9463813c560f9238d0 100644 --- a/protocol/jsonrpc/json.go +++ b/protocol/jsonrpc/json.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc diff --git a/protocol/jsonrpc/json_test.go b/protocol/jsonrpc/json_test.go index c821cc25f1ff93d8af4fd4cf7d405a6ad798a2ff..8d3ac5dabb69acbfc3ca9846ebd1575a53b32eb8 100644 --- a/protocol/jsonrpc/json_test.go +++ b/protocol/jsonrpc/json_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc diff --git a/protocol/jsonrpc/jsonrpc_exporter.go b/protocol/jsonrpc/jsonrpc_exporter.go index 144437c10402962b3356706b88f1e2701524a97b..21a2465cddde7709bf5a23f6247ecb74016bf129 100644 --- a/protocol/jsonrpc/jsonrpc_exporter.go +++ b/protocol/jsonrpc/jsonrpc_exporter.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -19,10 +22,10 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" ) type JsonrpcExporter struct { diff --git a/protocol/jsonrpc/jsonrpc_invoker.go b/protocol/jsonrpc/jsonrpc_invoker.go index 75ac88085ff396cde95e1ec2a43a7026777569de..2c130e0d7617e96a1724edc5b63f8e66f251446e 100644 --- a/protocol/jsonrpc/jsonrpc_invoker.go +++ b/protocol/jsonrpc/jsonrpc_invoker.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -19,11 +22,11 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" - invocation_impl "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + invocation_impl "github.com/apache/dubbo-go/protocol/invocation" ) type JsonrpcInvoker struct { diff --git a/protocol/jsonrpc/jsonrpc_invoker_test.go b/protocol/jsonrpc/jsonrpc_invoker_test.go index 2d248469e2bb35edb1708901615c444a0d712dd0..9641fb532148bc78562755ea4c55696142278951 100644 --- a/protocol/jsonrpc/jsonrpc_invoker_test.go +++ b/protocol/jsonrpc/jsonrpc_invoker_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -25,9 +28,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) func TestJsonrpcInvoker_Invoke(t *testing.T) { diff --git a/protocol/jsonrpc/jsonrpc_protocol.go b/protocol/jsonrpc/jsonrpc_protocol.go index 737c9cb175cedaae081abf6a43dfc605fb906d40..fa4071b4fd75ecc4f0be94f93d31c13a8cccb8f2 100644 --- a/protocol/jsonrpc/jsonrpc_protocol.go +++ b/protocol/jsonrpc/jsonrpc_protocol.go @@ -1,25 +1,28 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/config" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/protocol" ) const JSONRPC = "jsonrpc" diff --git a/protocol/jsonrpc/jsonrpc_protocol_test.go b/protocol/jsonrpc/jsonrpc_protocol_test.go index 09e43400cdc51431ccd3bcad1389b88f73fac485..866f3d72be7b907cd9e2a8e56528f1b76848646d 100644 --- a/protocol/jsonrpc/jsonrpc_protocol_test.go +++ b/protocol/jsonrpc/jsonrpc_protocol_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -25,9 +28,9 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/config" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/config" + "github.com/apache/dubbo-go/protocol" ) func TestJsonrpcProtocol_Export(t *testing.T) { diff --git a/protocol/jsonrpc/server.go b/protocol/jsonrpc/server.go index 1be5c54d239910c7da7b3fd955512e4120fed4da..a7643dc215e8ae1ef5f7e5b02236f881b0f963c9 100644 --- a/protocol/jsonrpc/server.go +++ b/protocol/jsonrpc/server.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang, Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package jsonrpc @@ -34,11 +37,11 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/logger" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/invocation" ) var ( diff --git a/protocol/protocol.go b/protocol/protocol.go index 03b2cfbe50c6757a0e86cf4d10385fef97cd8104..814a85163a99aa3b161b5eafbfed5f13ac4e3eb4 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocol @@ -19,8 +22,8 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" ) // Extension - protocol diff --git a/protocol/protocolwrapper/mock_protocol_filter.go b/protocol/protocolwrapper/mock_protocol_filter.go index 902ccefaa974a003b0eaf45c35d65c5c930b81f7..2efc34da4469cf369d4bbeb871ccfbdb73123f6a 100644 --- a/protocol/protocolwrapper/mock_protocol_filter.go +++ b/protocol/protocolwrapper/mock_protocol_filter.go @@ -1,29 +1,32 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocolwrapper import ( "sync" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" ) -type mockProtocolFilter struct { -} +type mockProtocolFilter struct{} func NewMockProtocolFilter() protocol.Protocol { return &mockProtocolFilter{} diff --git a/protocol/protocolwrapper/protocol_filter_wrapper.go b/protocol/protocolwrapper/protocol_filter_wrapper.go index e7cb227d51215b7a0bfc8e56fde86f1a5bf18777..b1392fff511dba2e2cbedf2547d6be2d4276a912 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper.go @@ -1,29 +1,32 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocolwrapper import ( - "github.com/dubbo/go-for-apache-dubbo/filter" "strings" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/filter" + "github.com/apache/dubbo-go/protocol" ) const ( diff --git a/protocol/protocolwrapper/protocol_filter_wrapper_test.go b/protocol/protocolwrapper/protocol_filter_wrapper_test.go index 49015cdc4b0ce813f7d46d34b3e8ff2a52db80b9..8131accfd3105d101042c1c51178f2794ebc47f6 100644 --- a/protocol/protocolwrapper/protocol_filter_wrapper_test.go +++ b/protocol/protocolwrapper/protocol_filter_wrapper_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocolwrapper @@ -24,11 +27,11 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/filter/impl" - "github.com/dubbo/go-for-apache-dubbo/protocol" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/filter/impl" + "github.com/apache/dubbo-go/protocol" ) func TestProtocolFilterWrapper_Export(t *testing.T) { diff --git a/protocol/result.go b/protocol/result.go index adcce8a5ec04ddd390d6eeea365fe9fe2553e123..f6e27280216641269cfc031888ea53176cc8b225 100644 --- a/protocol/result.go +++ b/protocol/result.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Yincheng Fang -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocol diff --git a/registry/directory/directory.go b/registry/directory/directory.go index c86bc2697edee6686a2e6af33c3d0554d5439212..32841be5f68b07b1f87d2080834de83debb53893 100644 --- a/registry/directory/directory.go +++ b/registry/directory/directory.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package directory @@ -20,25 +23,28 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" perrors "github.com/pkg/errors" ) import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/directory" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/protocolwrapper" - "github.com/dubbo/go-for-apache-dubbo/registry" + "github.com/apache/dubbo-go/cluster/directory" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/protocolwrapper" + "github.com/apache/dubbo-go/registry" ) -const RegistryConnDelay = 3 +const ( + RegistryConnDelay = 3 +) type Options struct { serviceTTL time.Duration } + type Option func(*Options) type registryDirectory struct { @@ -185,7 +191,7 @@ func (dir *registryDirectory) cacheInvoker(url common.URL) { referenceUrl := dir.GetUrl().SubURL //check the url's protocol is equal to the protocol which is configured in reference config or referenceUrl is not care about protocol if url.Protocol == referenceUrl.Protocol || referenceUrl.Protocol == "" { - url = mergeUrl(url, referenceUrl) + url = common.MergeUrl(url, referenceUrl) if _, ok := dir.cacheInvokersMap.Load(url.Key()); !ok { logger.Debugf("service will be added in cache invokers: invokers key is %s!", url.Key()) @@ -225,52 +231,3 @@ func (dir *registryDirectory) Destroy() { dir.cacheInvokers = []protocol.Invoker{} }) } - -// configuration > reference config >service config -// in this function we should merge the reference local url config into the service url from registry. -//TODO configuration merge, in the future , the configuration center's config should merge too. -func mergeUrl(serviceUrl common.URL, referenceUrl *common.URL) common.URL { - mergedUrl := serviceUrl - var methodConfigMergeFcn = []func(method string){} - //iterator the referenceUrl if serviceUrl not have the key ,merge in - - for k, v := range referenceUrl.Params { - if _, ok := mergedUrl.Params[k]; !ok { - mergedUrl.Params.Set(k, v[0]) - } - } - //loadBalance strategy config - if v := referenceUrl.Params.Get(constant.LOADBALANCE_KEY); v != "" { - mergedUrl.Params.Set(constant.LOADBALANCE_KEY, v) - } - methodConfigMergeFcn = append(methodConfigMergeFcn, func(method string) { - if v := referenceUrl.Params.Get(method + "." + constant.LOADBALANCE_KEY); v != "" { - mergedUrl.Params.Set(method+"."+constant.LOADBALANCE_KEY, v) - } - }) - - //cluster strategy config - if v := referenceUrl.Params.Get(constant.CLUSTER_KEY); v != "" { - mergedUrl.Params.Set(constant.CLUSTER_KEY, v) - } - methodConfigMergeFcn = append(methodConfigMergeFcn, func(method string) { - if v := referenceUrl.Params.Get(method + "." + constant.CLUSTER_KEY); v != "" { - mergedUrl.Params.Set(method+"."+constant.CLUSTER_KEY, v) - } - }) - - //remote timestamp - if v := serviceUrl.Params.Get(constant.TIMESTAMP_KEY); v != "" { - mergedUrl.Params.Set(constant.REMOTE_TIMESTAMP_KEY, v) - mergedUrl.Params.Set(constant.TIMESTAMP_KEY, referenceUrl.Params.Get(constant.TIMESTAMP_KEY)) - } - - //finally execute methodConfigMergeFcn - for _, method := range referenceUrl.Methods { - for _, fcn := range methodConfigMergeFcn { - fcn("methods." + method) - } - } - - return mergedUrl -} diff --git a/registry/directory/directory_test.go b/registry/directory/directory_test.go index 685e96a685bb3af2c6577d1ab24f1a87bef34a28..eafd3f7c17a47520bd91e99176814753f5d7ddef 100644 --- a/registry/directory/directory_test.go +++ b/registry/directory/directory_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package directory @@ -21,17 +24,19 @@ import ( "testing" "time" ) + import ( "github.com/stretchr/testify/assert" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol/invocation" - "github.com/dubbo/go-for-apache-dubbo/protocol/protocolwrapper" - "github.com/dubbo/go-for-apache-dubbo/registry" + "github.com/apache/dubbo-go/cluster/cluster_impl" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol/invocation" + "github.com/apache/dubbo-go/protocol/protocolwrapper" + "github.com/apache/dubbo-go/registry" ) func TestSubscribe(t *testing.T) { @@ -48,8 +53,8 @@ func TestSubscribe_Delete(t *testing.T) { mockRegistry.MockEvent(®istry.ServiceEvent{Action: registry.ServiceDel, Service: *common.NewURLWithOptions("TEST0", common.WithProtocol("dubbo"))}) time.Sleep(1e9) assert.Len(t, registryDirectory.cacheInvokers, 2) - } + func TestSubscribe_InvalidUrl(t *testing.T) { url, _ := common.NewURL(context.TODO(), "mock://127.0.0.1:1111") mockRegistry, _ := registry.NewMockRegistry(&common.URL{}) @@ -127,19 +132,3 @@ func normalRegistryDir() (*registryDirectory, *registry.MockRegistry) { } return registryDirectory, mockRegistry.(*registry.MockRegistry) } - -func TestMergeUrl(t *testing.T) { - referenceUrlParams := url.Values{} - referenceUrlParams.Set(constant.CLUSTER_KEY, "random") - referenceUrlParams.Set("test3", "1") - serviceUrlParams := url.Values{} - serviceUrlParams.Set("test2", "1") - serviceUrlParams.Set(constant.CLUSTER_KEY, "roundrobin") - referenceUrl, _ := common.NewURL(context.TODO(), "mock1://127.0.0.1:1111", common.WithParams(referenceUrlParams)) - serviceUrl, _ := common.NewURL(context.TODO(), "mock2://127.0.0.1:20000", common.WithParams(serviceUrlParams)) - - mergedUrl := mergeUrl(serviceUrl, &referenceUrl) - assert.Equal(t, "random", mergedUrl.GetParam(constant.CLUSTER_KEY, "")) - assert.Equal(t, "1", mergedUrl.GetParam("test2", "")) - assert.Equal(t, "1", mergedUrl.GetParam("test3", "")) -} diff --git a/registry/event.go b/registry/event.go index 51a21ac37ce0d2b7fbb82a4d88ad636dfec3ee9d..ef51bbbe1710b1fdb166d34af58c630a5203b53a 100644 --- a/registry/event.go +++ b/registry/event.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package registry @@ -19,8 +22,9 @@ import ( "math/rand" "time" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/common" + "github.com/apache/dubbo-go/common" ) func init() { diff --git a/registry/mock_registry.go b/registry/mock_registry.go index 16a0942b76918fc7bdd012d35dbb5a435d8d0a95..1fc700edb7cf37eb2613c90d458c58d278507faf 100644 --- a/registry/mock_registry.go +++ b/registry/mock_registry.go @@ -1,24 +1,28 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package registry import ( "go.uber.org/atomic" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/common" + "github.com/apache/dubbo-go/common" ) type MockRegistry struct { diff --git a/registry/protocol/protocol.go b/registry/protocol/protocol.go index 0c1789ac6593d33289d66d2d63689f95f534c1e4..ff33b5fe6e063257c12035f3262e0daae874363e 100644 --- a/registry/protocol/protocol.go +++ b/registry/protocol/protocol.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocol @@ -19,21 +22,20 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/protocolwrapper" + "github.com/apache/dubbo-go/registry" + directory2 "github.com/apache/dubbo-go/registry/directory" ) -import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/protocolwrapper" - "github.com/dubbo/go-for-apache-dubbo/registry" - directory2 "github.com/dubbo/go-for-apache-dubbo/registry/directory" +var ( + regProtocol *registryProtocol ) -var regProtocol *registryProtocol - type registryProtocol struct { invokers []protocol.Invoker // Registry Map<RegistryAddress, Registry> diff --git a/registry/protocol/protocol_test.go b/registry/protocol/protocol_test.go index f1bb2fc5a7e3125933c75e9786cfbffa0c5353fd..418f1f6779679b6eb93a74ff7689ca8e76f2c0af 100644 --- a/registry/protocol/protocol_test.go +++ b/registry/protocol/protocol_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package protocol @@ -18,17 +21,19 @@ import ( "context" "testing" ) + import ( "github.com/stretchr/testify/assert" ) + import ( - cluster "github.com/dubbo/go-for-apache-dubbo/cluster/cluster_impl" - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/protocol" - "github.com/dubbo/go-for-apache-dubbo/protocol/protocolwrapper" - "github.com/dubbo/go-for-apache-dubbo/registry" + cluster "github.com/apache/dubbo-go/cluster/cluster_impl" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/protocol/protocolwrapper" + "github.com/apache/dubbo-go/registry" ) func referNormal(t *testing.T, regProtocol *registryProtocol) { @@ -46,6 +51,7 @@ func referNormal(t *testing.T, regProtocol *registryProtocol) { assert.IsType(t, &protocol.BaseInvoker{}, invoker) assert.Equal(t, invoker.GetUrl().String(), url.String()) } + func TestRefer(t *testing.T) { regProtocol := newRegistryProtocol() referNormal(t, regProtocol) @@ -85,6 +91,7 @@ func TestOneRegRefer(t *testing.T) { }) assert.Equal(t, count, 1) } + func exporterNormal(t *testing.T, regProtocol *registryProtocol) { extension.SetProtocol("registry", GetProtocol) extension.SetRegistry("mock", registry.NewMockRegistry) diff --git a/registry/registry.go b/registry/registry.go index 28ca1a1c19d7e2ffa72797be7bdf221338c19a45..b41ac534ba7daa588bd47d3327383047358033bc 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -1,21 +1,24 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package registry import ( - "github.com/dubbo/go-for-apache-dubbo/common" + "github.com/apache/dubbo-go/common" ) // Extension - Registry diff --git a/registry/zookeeper/listener.go b/registry/zookeeper/listener.go index b6446e7fcc3dd46515e9e50ad2cdbc323263078e..711b876ef2bb2339423a56423155441ae54657f3 100644 --- a/registry/zookeeper/listener.go +++ b/registry/zookeeper/listener.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package zookeeper @@ -23,14 +26,14 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" perrors "github.com/pkg/errors" "github.com/samuel/go-zookeeper/zk" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/registry" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/registry" ) const ( diff --git a/registry/zookeeper/registry.go b/registry/zookeeper/registry.go index 4d553a1658a15416cbcf00c107aeffca11b5031b..5302c84c8e445026d6d9c68221249a46d263e09c 100644 --- a/registry/zookeeper/registry.go +++ b/registry/zookeeper/registry.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package zookeeper @@ -26,18 +29,18 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" perrors "github.com/pkg/errors" "github.com/samuel/go-zookeeper/zk" ) import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" - "github.com/dubbo/go-for-apache-dubbo/common/extension" - "github.com/dubbo/go-for-apache-dubbo/common/utils" - "github.com/dubbo/go-for-apache-dubbo/registry" - "github.com/dubbo/go-for-apache-dubbo/version" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/common/utils" + "github.com/apache/dubbo-go/registry" + "github.com/apache/dubbo-go/version" ) const ( diff --git a/registry/zookeeper/registry_test.go b/registry/zookeeper/registry_test.go index 3d230bb0a98eef74087f30e1adcf10427433ef7d..2e85e12f3a87df880b78dc70760efaa7e6dd8203 100644 --- a/registry/zookeeper/registry_test.go +++ b/registry/zookeeper/registry_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package zookeeper @@ -20,12 +23,14 @@ import ( "testing" "time" ) + import ( "github.com/stretchr/testify/assert" ) + import ( - "github.com/dubbo/go-for-apache-dubbo/common" - "github.com/dubbo/go-for-apache-dubbo/common/constant" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" ) func Test_Register(t *testing.T) { diff --git a/registry/zookeeper/zk_client.go b/registry/zookeeper/zk_client.go index 3721cc7b3223178f17507f761e9a8add69241188..bd273ff409f0bda2f0bf7e5f5cbdeaaad83fcce3 100644 --- a/registry/zookeeper/zk_client.go +++ b/registry/zookeeper/zk_client.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package zookeeper @@ -22,11 +25,14 @@ import ( ) import ( - "github.com/dubbo/go-for-apache-dubbo/common/logger" perrors "github.com/pkg/errors" "github.com/samuel/go-zookeeper/zk" ) +import ( + "github.com/apache/dubbo-go/common/logger" +) + var ( errNilZkClientConn = perrors.New("zookeeperclient{conn} is nil") ) @@ -102,6 +108,7 @@ func newZookeeperClient(name string, zkAddrs []string, timeout time.Duration) (* return z, nil } + func newMockZookeeperClient(name string, timeout time.Duration) (*zk.TestCluster, *zookeeperClient, <-chan zk.Event, error) { var ( err error @@ -302,7 +309,7 @@ func (z *zookeeperClient) Create(basePath string) error { z.Unlock() if err != nil { if err == zk.ErrNodeExists { - logger.Errorf("zk.create(\"%s\") exists\n", tmpPath) + logger.Infof("zk.create(\"%s\") exists\n", tmpPath) } else { logger.Errorf("zk.create(\"%s\") error(%v)\n", tmpPath, perrors.WithStack(err)) return perrors.WithMessagef(err, "zk.Create(path:%s)", basePath) diff --git a/registry/zookeeper/zk_client_test.go b/registry/zookeeper/zk_client_test.go index 808b6fcff9d173e406adbc669a8c0b82b41ea3a3..ff98bb5bc783da0908c5f3cbe28c94385b0bd1db 100644 --- a/registry/zookeeper/zk_client_test.go +++ b/registry/zookeeper/zk_client_test.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 hxmhlt -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package zookeeper @@ -19,6 +22,7 @@ import ( "testing" "time" ) + import ( "github.com/samuel/go-zookeeper/zk" "github.com/stretchr/testify/assert" @@ -43,6 +47,7 @@ func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk. } } } + func verifyEventOrder(t *testing.T, c <-chan zk.Event, expectedEvent []zk.EventType, source string) { for _, e := range expectedEvent { for { diff --git a/version/version.go b/version/version.go index ff30d03190da19411333ecceb857690d462bb10b..b9a076e78cbf0c9c7b5172e1b30c84f60f250ea7 100644 --- a/version/version.go +++ b/version/version.go @@ -1,16 +1,19 @@ -// Copyright 2016-2019 Alex Stocks -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package version