-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from dubbo-x/consul
Ftr: consul registry
- Loading branch information
Showing
37 changed files
with
1,792 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,9 +17,9 @@ coverage.txt | |
target/ | ||
classes | ||
|
||
|
||
# Gopkg.lock | ||
# go mod, go test | ||
vendor/ | ||
coverage.txt | ||
|
||
logs/ | ||
.vscode/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# consul | ||
|
||
Examples for consul registry. Before running examples below, make sure that consul has been started. | ||
|
||
## requirement | ||
|
||
- consul | ||
- go 1.12 | ||
- java 8 | ||
- maven 3.6.1 | ||
|
||
## go-server | ||
|
||
``` | ||
$ cd examples/consul/go-server | ||
$ export CONF_PROVIDER_FILE_PATH="config/server.yml" | ||
$ export APP_LOG_CONF_FILE="config/log.yml" | ||
$ go run . | ||
``` | ||
|
||
## go-client | ||
|
||
``` | ||
$ cd examples/consul/go-client | ||
$ export CONF_CONSUMER_FILE_PATH="config/client.yml" | ||
$ export APP_LOG_CONF_FILE="config/log.yml" | ||
$ go run . | ||
``` | ||
|
||
## java-server | ||
|
||
``` | ||
$ cd examples/consul/java-server | ||
$ mvn clean package | ||
$ java -jar target/java-server-1.0.0.jar | ||
``` | ||
|
||
## java-client | ||
|
||
``` | ||
$ cd examples/consul/java-client | ||
$ mvn clean package | ||
$ java -jar target/java-client-1.0.0.jar | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
import ( | ||
_ "github.com/apache/dubbo-go/cluster/cluster_impl" | ||
_ "github.com/apache/dubbo-go/cluster/loadbalance" | ||
_ "github.com/apache/dubbo-go/common/proxy/proxy_factory" | ||
"github.com/apache/dubbo-go/config" | ||
_ "github.com/apache/dubbo-go/filter/impl" | ||
_ "github.com/apache/dubbo-go/protocol/dubbo" | ||
_ "github.com/apache/dubbo-go/registry/consul" | ||
_ "github.com/apache/dubbo-go/registry/protocol" | ||
) | ||
|
||
func main() { | ||
config.Load() | ||
|
||
message, err := dubboService.SayHello([]interface{}{"world"}) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(message) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
application_config: | ||
organization : "ikurento.com" | ||
name : "BDTService" | ||
module : "dubbogo user-info client" | ||
version : "0.0.1" | ||
owner : "ZX" | ||
environment : "test" | ||
|
||
registries : | ||
"consul": | ||
protocol: "consul" | ||
timeout : "3s" | ||
address: "127.0.0.1:8500" | ||
username: "" | ||
password: "" | ||
|
||
references: | ||
"DubboService": | ||
protocol : "dubbo" | ||
interface : "dubbo.DubboService" | ||
cluster: "failover" | ||
methods : | ||
- name: "SayHello" | ||
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" | ||
|
||
check: true | ||
request_timeout : "3s" | ||
connect_timeout : "3s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
level: "info" | ||
development: false | ||
disableCaller: false | ||
disableStacktrace: true | ||
sampling: | ||
encoding: "console" | ||
|
||
# encoder | ||
encoderConfig: | ||
messageKey: "message" | ||
levelKey: "level" | ||
timeKey: "time" | ||
nameKey: "logger" | ||
callerKey: "caller" | ||
stacktraceKey: "stacktrace" | ||
lineEnding: "" | ||
levelEncoder: "capitalColor" | ||
timeEncoder: "iso8601" | ||
durationEncoder: "seconds" | ||
callerEncoder: "short" | ||
nameEncoder: "" | ||
|
||
outputPaths: | ||
- "stderr" | ||
errorOutputPaths: | ||
- "stderr" | ||
initialFields: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 | ||
|
||
import ( | ||
"github.com/apache/dubbo-go/config" | ||
) | ||
|
||
var dubboService = new(DubboService) | ||
|
||
func init() { | ||
config.SetConsumerService(dubboService) | ||
} | ||
|
||
type DubboService struct { | ||
SayHello func(req interface{}) (string, error) | ||
} | ||
|
||
func (s *DubboService) Reference() string { | ||
return "DubboService" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
level: "info" | ||
development: false | ||
disableCaller: false | ||
disableStacktrace: true | ||
sampling: | ||
encoding: "console" | ||
|
||
# encoder | ||
encoderConfig: | ||
messageKey: "message" | ||
levelKey: "level" | ||
timeKey: "time" | ||
nameKey: "logger" | ||
callerKey: "caller" | ||
stacktraceKey: "stacktrace" | ||
lineEnding: "" | ||
levelEncoder: "capitalColor" | ||
timeEncoder: "iso8601" | ||
durationEncoder: "seconds" | ||
callerEncoder: "short" | ||
nameEncoder: "" | ||
|
||
outputPaths: | ||
- "stderr" | ||
errorOutputPaths: | ||
- "stderr" | ||
initialFields: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
application_config: | ||
organization : "ikurento.com" | ||
name : "BDTService" | ||
module : "dubbogo user-info server" | ||
version : "0.0.1" | ||
owner : "ZX" | ||
environment : "test" | ||
|
||
registries : | ||
"consul": | ||
protocol: "consul" | ||
timeout : "3s" | ||
address: "127.0.0.1:8500" | ||
username: "" | ||
password: "" | ||
|
||
services: | ||
"DubboService": | ||
protocol : "dubbo" | ||
interface : "dubbo.DubboService" | ||
loadbalance: "random" | ||
warmup: "100" | ||
cluster: "failover" | ||
methods: | ||
- name: "SayHello" | ||
retries: 1 | ||
loadbalance: "random" | ||
|
||
protocols: | ||
"dubbo1": | ||
name: "dubbo" | ||
port: 20000 | ||
|
||
protocol_conf: | ||
dubbo: | ||
session_number: 700 | ||
fail_fast_timeout: "5s" | ||
session_timeout: "20s" | ||
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: 1024 | ||
session_name: "server" |
Oops, something went wrong.