This is an automated email from the ASF dual-hosted git repository.
tianxiaoliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 34b50b1 [feat] add datacenter info to instance from config (#1208)
34b50b1 is described below
commit 34b50b173c3e7a541d449312a58dda52452ef8f7
Author: xiaoluoluo <[email protected]>
AuthorDate: Mon Jan 10 14:11:41 2022 +0800
[feat] add datacenter info to instance from config (#1208)
Co-authored-by: [email protected] <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>
---
etc/conf/app.yaml | 4 ++++
server/core/microservice.go | 11 +++++++++++
2 files changed, 15 insertions(+)
diff --git a/etc/conf/app.yaml b/etc/conf/app.yaml
index 91618d3..2c4dbd3 100644
--- a/etc/conf/app.yaml
+++ b/etc/conf/app.yaml
@@ -144,6 +144,10 @@ registry:
# the allowable minimum value of instance heartbeat interval
# if interval < minInterval, instance TTL still set with minInterval
minInterval: 5s
+ datacenter:
+ name:
+ region:
+ availableZone:
schema:
# if want disable Test Schema, SchemaDisable set true
diff --git a/server/core/microservice.go b/server/core/microservice.go
index 84f1901..1132a61 100644
--- a/server/core/microservice.go
+++ b/server/core/microservice.go
@@ -74,6 +74,17 @@ func InitRegistration() {
Times: RegistryDefaultLeaseRetryTimes,
},
}
+
+ name := config.GetString("registry.instance.datacenter.name", " ")
+ region := config.GetString("registry.instance.datacenter.region", " ")
+ availableZone :=
config.GetString("registry.instance.datacenter.availableZone", " ")
+ if len(name) > 0 && len(region) > 0 && len(availableZone) > 0 {
+ Instance.DataCenterInfo = &discovery.DataCenterInfo{
+ Name: name,
+ Region: region,
+ AvailableZone: availableZone,
+ }
+ }
}
func AddDefaultContextValue(ctx context.Context) context.Context {