Skip to content

Commit

Permalink
upgrade lager (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiaoliang committed Sep 25, 2018
1 parent 8ea969a commit 56298fa
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 17 deletions.
2 changes: 1 addition & 1 deletion core/registry/bootstrap.go
Expand Up @@ -117,7 +117,7 @@ func refreshDependency(service *MicroService) error {

// RegisterMicroserviceInstances register micro-service instances
func RegisterMicroserviceInstances() error {
lager.Logger.Info("Start to register instance.", nil)
lager.Logger.Info("Start to register instance.")
service := config.MicroserviceDefinition
var err error

Expand Down
2 changes: 1 addition & 1 deletion core/registry/discovery.go
Expand Up @@ -80,7 +80,7 @@ func enableContractDiscovery(opts Options) {
}
f := cdFunc[t]
if f == nil {
lager.Logger.Warn("No contract discovery plugin", nil)
lager.Logger.Warn("No contract discovery plugin")
return
}
DefaultContractDiscoveryService = f(opts)
Expand Down
2 changes: 1 addition & 1 deletion core/registry/heartbeat.go
Expand Up @@ -136,7 +136,7 @@ func (s *HeartbeatService) RetryRegister(sid, iid string) error {
break
}
}
lager.Logger.Warn("Re-register self success", nil)
lager.Logger.Warn("Re-register self success")
return nil
}

Expand Down
3 changes: 2 additions & 1 deletion core/router/cse/darklaunch.go
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/go-chassis/go-chassis/core/archaius"
"github.com/go-chassis/go-chassis/core/config/model"
"github.com/go-chassis/go-chassis/core/lager"
"github.com/go-mesh/openlogging"
)

// RouteDarkLaunchGovernSourceName is source name of dark launch configuration
Expand Down Expand Up @@ -104,7 +105,7 @@ func (r *RouteDarkLaunchGovernSource) Callback(e *core.Event) {
}
lager.Logger.Debugf("Get event, key: %s, type: %s", e.Key, e.EventType)
if r.d == nil {
lager.Logger.Warn("Dynamic config handler is nil", nil)
openlogging.GetLogger().Warn("Dynamic config handler is nil")
return
}
r.d.OnEvent(e)
Expand Down
3 changes: 2 additions & 1 deletion core/router/cse/router_manager.go
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-chassis/go-chassis/core/lager"
"github.com/go-chassis/go-chassis/core/router"
wp "github.com/go-chassis/go-chassis/core/router/weightpool"
"github.com/go-mesh/openlogging"
)

const routeFileSourceName = "RouteFileSource"
Expand All @@ -23,7 +24,7 @@ type routeRuleEventListener struct{}
// update route rule of a service
func (r *routeRuleEventListener) Event(e *core.Event) {
if e == nil {
lager.Logger.Warn("Event pointer is nil", nil)
openlogging.GetLogger().Warn("Event pointer is nil")
return
}

Expand Down
5 changes: 3 additions & 2 deletions core/router/pilot/pilotsource.go
Expand Up @@ -16,6 +16,7 @@ import (
wp "github.com/go-chassis/go-chassis/core/router/weightpool"
"github.com/go-chassis/go-chassis/pkg/istio/client"
"github.com/go-chassis/go-chassis/pkg/istio/util"
"github.com/go-mesh/openlogging"
)

const routePilotSourceName = "RoutePilotSource"
Expand Down Expand Up @@ -260,7 +261,7 @@ type pilotEventListener struct{}
// update route rule of a service
func (r *pilotEventListener) Event(e *core.Event) {
if e == nil {
lager.Logger.Warn("pilot event pointer is nil", nil)
lager.Logger.Warn("pilot event pointer is nil")
return
}

Expand All @@ -272,7 +273,7 @@ func (r *pilotEventListener) Event(e *core.Event) {
}
routeRules, ok := v.([]*model.RouteRule)
if !ok {
lager.Logger.Error("value of pilot is not type []*RouteRule", nil)
openlogging.GetLogger().Error("value of pilot is not type []*RouteRule")
return
}

Expand Down
32 changes: 26 additions & 6 deletions docs/user-guides/invoker.md
@@ -1,15 +1,15 @@
# Invoker
## 概述
## Introduction

---

框架提供Rest调用与RPC调用2种方式
Invoker is the entry point for a developer to call remote service

## API

#### Rest调用
#### Rest Invoker

使用NewRestInvoker创建一个invoker实例,可接受chain, filters等自定义选项
使用NewRestInvoker创建一个invoker实例,可接受chain等自定义选项

ContextDo可以接受一个http request作为参数,开发者可通过request的API对request进行操作,并作为参数传入该方法

Expand All @@ -18,7 +18,7 @@ func NewRestInvoker(opt ...Option) *RestInvoker
func (ri *RestInvoker) ContextDo(ctx context.Context, req *rest.Request, options ...InvocationOption) (*rest.Response, error)
```

#### RPC调用
#### RPC Invoker

使用NewRPCInvoker创建invoker实例,可接受chain, filters等自定义选项

Expand All @@ -33,7 +33,7 @@ func (ri *RPCInvoker) Invoke(ctx context.Context, microServiceName, schemaID, op

无论Rest还是RPC调用方法都能够接受多种选项对一次调用进行控制,参考options.go查看更多选项

## 示例
## Examples

#### RPC

Expand All @@ -58,5 +58,25 @@ defer req.Close()
resp, err := core.NewRestInvoker(core.ChainName("custom")).ContextDo(context.TODO(), req)
```

#### Multiple Port
if you define different port for the same protocol, like below
```go
cse:
protocols:
rest:
listenAddress: 0.0.0.0:5000
rest-admin:
listenAddress: 0.0.0.0:5001
```
then you can use suffix "admin" as port to access rest-admin server
```go
req, _ := rest.NewRequest("GET", "cse://RESTServer:admin/sayhello/world")
```
use only service name to access rest server
```go
req, _ := rest.NewRequest("GET", "cse://RESTServer/sayhello/world")
```




4 changes: 2 additions & 2 deletions go.mod
Expand Up @@ -21,9 +21,9 @@ require (
github.com/go-chassis/go-cc-client v0.0.0-20180831085349-c2bb6cef1640
github.com/go-chassis/go-chassis-plugins v0.0.0-20180731065901-7b05d8d2fbe6
github.com/go-chassis/go-sc-client v0.0.0-20180831081217-8135c6df7f96
github.com/go-chassis/paas-lager v0.0.0-20180831030822-312e8737a225
github.com/go-chassis/paas-lager master
github.com/go-logfmt/logfmt v0.3.0 // indirect
github.com/go-mesh/openlogging v0.0.0-20180831021158-f5d1c4e7e506
github.com/go-mesh/openlogging master
github.com/go-ole/go-ole v1.2.1 // indirect
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.1.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions server/restful/restful_server.go
Expand Up @@ -225,8 +225,8 @@ func (r *restfulServer) Start() error {
err = r.server.ListenAndServe()
}
if err != nil {
lager.Logger.Error("Can't start http server",
openlogging.Tags{"err": err.Error()})
openlogging.GetLogger().Error("Can't start http server",
openlogging.WithTags(openlogging.Tags{"err": err.Error()}))
server.ErrRuntime <- err
}

Expand Down

0 comments on commit 56298fa

Please sign in to comment.