Skip to content

Commit

Permalink
Upgrade go-chassis (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
humingcheng authored Sep 1, 2020
1 parent 04eaa6a commit 3e7ec96
Show file tree
Hide file tree
Showing 47 changed files with 173 additions and 154 deletions.
15 changes: 7 additions & 8 deletions conf/chassis.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
---
cse:
servicecomb:
protocols:
grpc:
listenAddress: 127.0.0.1:40101
http:
listenAddress: 127.0.0.1:30101
rest-admin:
listenAddress: 127.0.0.1:30102 # listen addr use to adminAPI
service:
registry:
address: http://127.0.0.1:30100 # uri of service center
#address: https://cse.cn-north-1.myhuaweicloud.com:443 # uri of service center
scope: full #set full to be able to discover other app's service
watch: false # set if you want to watch instance change event
autoIPIndex: true # set to true if u want to resolve source IP to microservice
registry:
address: http://127.0.0.1:30100 # uri of service center
#address: https://cse.cn-north-1.myhuaweicloud.com:443 # uri of service center
scope: full #set full to be able to discover other app's service
watch: false # set if you want to watch instance change event
autoIPIndex: true # set to true if u want to resolve source IP to microservice
# config:
# client:
# serverUri: https://cse.cn-north-1.myhuaweicloud.com:443 #uri of config center
Expand Down
2 changes: 1 addition & 1 deletion conf/fault.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cse:
#servicecomb:
# governance:
# Consumer:
# _global: #最低优先级配置
Expand Down
13 changes: 7 additions & 6 deletions conf/microservice.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## microservice property
service_description:
name: hellomesher
version: 0.0.1
environment: #microservice environment
properties:
allowCrossApp: false #whether to allow calls across applications
servicecomb:
service:
name: hellomesher
version: 0.0.1
environment: #microservice environment
properties:
allowCrossApp: false #whether to allow calls across applications
2 changes: 1 addition & 1 deletion docker/edge/chassis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

---
cse:
servicecomb:
protocols:
http:
listenAddress: 127.0.0.1:30101
Expand Down
7 changes: 4 additions & 3 deletions docker/edge/microservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

service_description:
name: mesher-edge
version: 1.7.0
servicecomb:
service:
name: mesher-edge
version: 1.7.0
2 changes: 1 addition & 1 deletion examples/config/cse/conf/chassis.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
cse:
servicecomb:
protocols:
http:
listenAddress: 127.0.0.1:30101
Expand Down
2 changes: 1 addition & 1 deletion examples/config/cse/conf/fault.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cse:
#servicecomb:
# governance:
# Consumer:
# _global: #最低优先级配置
Expand Down
15 changes: 8 additions & 7 deletions examples/config/cse/conf/microservice.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## microservice property
APPLICATION_ID: mesher
service_description:
name: hellomesher
version: 0.0.1
environment: #microservice environment
properties:
allowCrossApp: false #whether to allow calls across applications
servicecomb:
service:
app: mesher
name: hellomesher
version: 0.0.1
environment: #microservice environment
properties:
allowCrossApp: false #whether to allow calls across applications
2 changes: 1 addition & 1 deletion examples/edge/conf/chassis.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
cse:
servicecomb:
protocols:
http:
listenAddress: 127.0.0.1:30101
Expand Down
7 changes: 4 additions & 3 deletions examples/edge/conf/microservice.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
service_description:
name: mesher-edge
version: 1.7.0
servicecomb:
service:
name: mesher-edge
version: 1.7.0
2 changes: 1 addition & 1 deletion examples/quick_start/mersher_calculator/conf/chassis.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
cse:
servicecomb:
protocols:
grpc:
listenAddress: 192.168.88.64:40107
Expand Down
2 changes: 1 addition & 1 deletion examples/quick_start/mersher_calculator/conf/fault.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cse:
#servicecomb:
# governance:
# Consumer:
# _global: #最低优先级配置
Expand Down
13 changes: 7 additions & 6 deletions examples/quick_start/mersher_calculator/conf/microservice.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## microservice property
service_description:
name: calculator
version: 1.1.1
environment: #microservice environment
properties:
allowCrossApp: true #whether to allow calls across applications
servicecomb:
service:
name: calculator
version: 1.1.1
environment: #microservice environment
properties:
allowCrossApp: true #whether to allow calls across applications
2 changes: 1 addition & 1 deletion examples/quick_start/mersher_webapp/conf/chassis.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
cse:
servicecomb:
protocols:
grpc:
listenAddress: 192.168.88.64:40101
Expand Down
2 changes: 1 addition & 1 deletion examples/quick_start/mersher_webapp/conf/fault.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cse:
#servicecomb:
# governance:
# Consumer:
# _global: #最低优先级配置
Expand Down
13 changes: 7 additions & 6 deletions examples/quick_start/mersher_webapp/conf/microservice.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## microservice property
service_description:
name: webapp
version: 0.0.1
environment: #microservice environment
properties:
allowCrossApp: true #whether to allow calls across applications
servicecomb:
service:
name: webapp
version: 0.0.1
environment: #microservice environment
properties:
allowCrossApp: true #whether to allow calls across applications
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
cse:
servicecomb:
protocols:
grpc:
listenAddress: 192.168.88.64:40102
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#cse:
#servicecomb:
# governance:
# Consumer:
# _global: #最低优先级配置
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
## microservice property
service_description:
name: calculator
version: 1.1.1
environment: #microservice environment
properties:
allowCrossApp: true #whether to allow calls across applications
servicecomb:
service:
name: calculator
version: 1.1.1
environment: #microservice environment
properties:
allowCrossApp: true #whether to allow calls across applications
17 changes: 9 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,25 @@ module github.com/apache/servicecomb-mesher
require (
github.com/envoyproxy/go-control-plane v0.6.0
github.com/ghodss/yaml v1.0.0
github.com/go-chassis/foundation v0.1.1-0.20191113114104-2b05871e9ec4
github.com/go-chassis/go-archaius v1.3.2
github.com/go-chassis/go-chassis v1.8.2-0.20200728122719-5c6c673368c5
github.com/go-chassis/foundation v0.1.1-0.20200825060850-b16bf420f7b3
github.com/go-chassis/go-archaius v1.3.3
github.com/go-chassis/go-chassis v1.8.2-0.20200831084354-7ac56be1a686
github.com/go-chassis/gohessian v0.0.0-20180702061429-e5130c25af55
github.com/go-chassis/openlog v1.1.1
github.com/go-mesh/openlogging v1.0.1
github.com/gogo/googleapis v1.3.1 // indirect
github.com/gogo/protobuf v1.3.0
github.com/lyft/protoc-gen-validate v0.1.0 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/prometheus/client_golang v0.9.1
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f
github.com/stretchr/testify v1.4.0
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4
github.com/stretchr/testify v1.5.1
github.com/tetratelabs/go2sky v0.1.1-0.20190703154722-1eaab8035277
github.com/urfave/cli v1.20.1-0.20181029213200-b67dcf995b6a
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
google.golang.org/grpc v1.19.1
gopkg.in/yaml.v2 v2.2.4
google.golang.org/grpc v1.27.0
gopkg.in/yaml.v2 v2.3.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.17.0
)
Expand Down
8 changes: 5 additions & 3 deletions proxy/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package bootstrap

import (
"fmt"
"log"
"strings"

Expand All @@ -38,6 +39,7 @@ import (
chassisHandler "github.com/go-chassis/go-chassis/core/handler"
"github.com/go-chassis/go-chassis/core/lager"
"github.com/go-chassis/go-chassis/core/metadata"
"github.com/go-chassis/openlog"
"github.com/go-mesh/openlogging"
)

Expand All @@ -56,7 +58,7 @@ func Start() error {
return err
}
if err := metrics.Init(); err != nil {
lager.Logger.Infof("metrics init error", err)
lager.Logger.Info("metrics init error", openlog.WithTags(openlog.Tags{"err": err}))
}
if err := v1.Init(); err != nil {
log.Println("Error occurred in starting admin server", err)
Expand All @@ -65,9 +67,9 @@ func Start() error {
return err
}
if cmd.Configs.LocalServicePorts == "" {
lager.Logger.Warnf("local service ports is missing, service can not be called by mesher")
lager.Logger.Warn("local service ports is missing, service can not be called by mesher")
} else {
lager.Logger.Infof("local service ports is [%v]", cmd.Configs.PortsMap)
lager.Logger.Info(fmt.Sprintf("local service ports is [%v]", cmd.Configs.PortsMap))
}
err := egress.Init()
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions proxy/bootstrap/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestBootstrap(t *testing.T) {
Listen: "127.0.0.1:90909",
}
config.GlobalDefinition = &model.GlobalCfg{
Cse: model.CseStruct{
ServiceComb: model.ServiceComb{
Protocols: protoMap,
},
}
Expand Down Expand Up @@ -112,7 +112,7 @@ func TestBootstrap(t *testing.T) {

t.Run("Test Start", func(t *testing.T) {
// case Protocols is empty
config.GlobalDefinition.Cse.Protocols = map[string]model.Protocol{}
config.GlobalDefinition.ServiceComb.Protocols = map[string]model.Protocol{}
err := Start()
assert.Error(t, err)

Expand Down
4 changes: 2 additions & 2 deletions proxy/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ func GetConfigFilePath(key string) (string, error) {
//InitProtocols initiates protocols
func InitProtocols() error {
// todo if sdk init failed, do not call the data
if len(config.GlobalDefinition.Cse.Protocols) == 0 {
config.GlobalDefinition.Cse.Protocols = map[string]model.Protocol{
if len(config.GlobalDefinition.ServiceComb.Protocols) == 0 {
config.GlobalDefinition.ServiceComb.Protocols = map[string]model.Protocol{
common.HTTPProtocol: {Listen: "127.0.0.1:30101"},
}

Expand Down
4 changes: 2 additions & 2 deletions proxy/handler/oauth2/oauth2_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func initHandler() handler.Chain {
func initInv() *invocation.Invocation {

config.GlobalDefinition = &model.GlobalCfg{}
config.GlobalDefinition.Cse.Handler.Chain.Provider = make(map[string]string)
config.GlobalDefinition.Cse.Handler.Chain.Provider["outgoing"] = AuthName
config.GlobalDefinition.ServiceComb.Handler.Chain.Provider = make(map[string]string)
config.GlobalDefinition.ServiceComb.Handler.Chain.Provider["outgoing"] = AuthName

var i *invocation.Invocation

Expand Down
8 changes: 4 additions & 4 deletions proxy/handler/port_rewrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func TestPortRewriteHandler_ValidEndpoint(t *testing.T) {
c.AddHandler(&PortSelectionHandler{})

config.GlobalDefinition = &model.GlobalCfg{}
config.GlobalDefinition.Cse.Handler.Chain.Consumer = make(map[string]string)
config.GlobalDefinition.Cse.Handler.Chain.Consumer["outgoing"] = PortMapForPilot
config.GlobalDefinition.ServiceComb.Handler.Chain.Consumer = make(map[string]string)
config.GlobalDefinition.ServiceComb.Handler.Chain.Consumer["outgoing"] = PortMapForPilot
i := &invocation.Invocation{
MicroServiceName: "service1",
SchemaID: "schema1",
Expand All @@ -56,8 +56,8 @@ func TestPortRewriteHandler_InValidEndpoint(t *testing.T) {
c.AddHandler(&PortSelectionHandler{})

config.GlobalDefinition = &model.GlobalCfg{}
config.GlobalDefinition.Cse.Handler.Chain.Consumer = make(map[string]string)
config.GlobalDefinition.Cse.Handler.Chain.Consumer["outgoing"] = PortMapForPilot
config.GlobalDefinition.ServiceComb.Handler.Chain.Consumer = make(map[string]string)
config.GlobalDefinition.ServiceComb.Handler.Chain.Consumer["outgoing"] = PortMapForPilot
i := &invocation.Invocation{
MicroServiceName: "service1",
SchemaID: "schema1",
Expand Down
12 changes: 6 additions & 6 deletions proxy/handler/skywalking_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const (

//initGcConfig
func initGcConfig() {
var micCfg model.MicroserviceCfg
micCfg.ServiceDescription.Name = "TEST"
var micCfg model.ServiceSpec
micCfg.Name = "TEST"
gcconfig.MicroserviceDefinition = &micCfg
}

Expand Down Expand Up @@ -79,8 +79,8 @@ func TestProvierHandle(t *testing.T) {
c.AddHandler(mhandler.NewSkyWalkingProvier())

gcconfig.GlobalDefinition = &model.GlobalCfg{}
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer = make(map[string]string)
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer["skywalking-provider"] = "skywalking-provider"
gcconfig.GlobalDefinition.ServiceComb.Handler.Chain.Consumer = make(map[string]string)
gcconfig.GlobalDefinition.ServiceComb.Handler.Chain.Consumer["skywalking-provider"] = "skywalking-provider"

c.Next(initInv(), func(r *invocation.Response) {
assert.Equal(t, r.Err, nil)
Expand Down Expand Up @@ -109,8 +109,8 @@ func TestConsumerHandle(t *testing.T) {
c.AddHandler(mhandler.NewSkyWalkingConsumer())

gcconfig.GlobalDefinition = &model.GlobalCfg{}
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer = make(map[string]string)
gcconfig.GlobalDefinition.Cse.Handler.Chain.Consumer["skywalking-consumer"] = "skywalking-consumer"
gcconfig.GlobalDefinition.ServiceComb.Handler.Chain.Consumer = make(map[string]string)
gcconfig.GlobalDefinition.ServiceComb.Handler.Chain.Consumer["skywalking-consumer"] = "skywalking-consumer"

c.Next(initInv(), func(r *invocation.Response) {
assert.Equal(t, r.Err, nil)
Expand Down
7 changes: 4 additions & 3 deletions proxy/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package health

import (
"errors"
"fmt"
"github.com/apache/servicecomb-mesher/proxy/config"
"github.com/go-chassis/go-chassis/core/lager"
"github.com/go-chassis/go-chassis/core/registry"
Expand Down Expand Up @@ -101,7 +102,7 @@ func runCheckers(c *config.HealthCheck, l7check L7Check, address string, deal De
for range ticker.C {
err := CheckService(c, l7check, address)
if err != nil {
lager.Logger.Errorf("health check failed for service port[%s]: %s", c.Port, err)
lager.Logger.Error(fmt.Sprintf("health check failed for service port[%s]: %s", c.Port, err))
}
deal(err)
}
Expand All @@ -111,7 +112,7 @@ func runCheckers(c *config.HealthCheck, l7check L7Check, address string, deal De

//CheckService check service health based on config
func CheckService(c *config.HealthCheck, l7check L7Check, address string) error {
lager.Logger.Debugf("check port [%s]", c.Port)
lager.Logger.Debug(fmt.Sprintf("check port [%s]", c.Port))
if l7check != nil {
if err := l7check(c, address); err != nil {
return err
Expand Down Expand Up @@ -141,7 +142,7 @@ func L4Check(address string) error {
func Run() error {
openlogging.Info("local health manager start")
for _, v := range config.GetConfig().HealthCheck {
lager.Logger.Debugf("check local health [%s],protocol [%s]", v.Port, v.Protocol)
lager.Logger.Debug(fmt.Sprintf("check local health [%s],protocol [%s]", v.Port, v.Protocol))
address, check, err := ParseConfig(v)
if err != nil {
lager.Logger.Warn("Health keeper can not check health")
Expand Down
Loading

0 comments on commit 3e7ec96

Please sign in to comment.