Skip to content
Snippets Groups Projects
Commit 3a793783 authored by 李志信's avatar 李志信
Browse files

fix: fix merge conflict

parents 63a5c864 fdb4d53b
No related branches found
No related tags found
No related merge requests found
......@@ -58,7 +58,6 @@ jobs:
run: |
make verify
- name: Integrate Test
run: |
chmod +x integrate_test.sh && ./integrate_test.sh
......
......@@ -128,6 +128,7 @@ const (
TAG_ROUTE_PROTOCOL = "tag"
PROVIDERS_CATEGORY = "providers"
ROUTER_KEY = "router"
EXPORT_KEY = "export"
)
const (
......
......@@ -435,6 +435,13 @@ func (c *URL) SetParam(key string, value string) {
c.params.Set(key, value)
}
// DelParam will delete the given key from the url
func (c *URL) DelParam(key string) {
c.paramsLock.Lock()
defer c.paramsLock.Unlock()
c.params.Del(key)
}
// ReplaceParams will replace the URL.params
// usually it should only be invoked when you want to modify an url, such as MergeURL
func (c *URL) ReplaceParams(param url.Values) {
......
......@@ -78,6 +78,7 @@ type ServiceConfig struct {
Protocols map[string]*ProtocolConfig
unexported *atomic.Bool
exported *atomic.Bool
export bool // a flag to control whether the current service should export or not
rpcService common.RPCService
cacheMutex sync.Mutex
cacheProtocol protocol.Protocol
......@@ -102,6 +103,7 @@ func (c *ServiceConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
}
c.exported = atomic.NewBool(false)
c.unexported = atomic.NewBool(false)
c.export = true
return nil
}
......@@ -112,6 +114,7 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig {
id: id,
unexported: atomic.NewBool(false),
exported: atomic.NewBool(false),
export: true,
}
}
......@@ -198,7 +201,12 @@ func (c *ServiceConfig) Export() error {
ivkURL.AddParam(constant.Tagkey, c.Tag)
}
// post process the URL to be exported
c.postProcessConfig(ivkURL)
// config post processor may set "export" to false
if !ivkURL.GetParamBool(constant.EXPORT_KEY, true) {
return nil
}
if len(regUrls) > 0 {
c.cacheMutex.Lock()
......@@ -306,6 +314,9 @@ func (c *ServiceConfig) getUrlMap() url.Values {
urlMap.Set(constant.SERVICE_AUTH_KEY, c.Auth)
urlMap.Set(constant.PARAMTER_SIGNATURE_ENABLE_KEY, c.ParamSign)
// whether to export or not
urlMap.Set(constant.EXPORT_KEY, strconv.FormatBool(c.export))
for _, v := range c.Methods {
prefix := "methods." + v.Name + "."
urlMap.Set(prefix+constant.LOADBALANCE_KEY, v.LoadBalance)
......
......@@ -20,6 +20,7 @@ package filter
import (
"context"
)
import (
"github.com/apache/dubbo-go/protocol"
)
......
......@@ -38,13 +38,14 @@ import (
"github.com/apache/dubbo-go/protocol"
)
// Integrate Sentinel Go MUST HAVE:
// 1. Must initialize Sentinel Go run environment,
// refer to https://github.com/alibaba/sentinel-golang/blob/master/api/init.go
// 2. Register rules for resources user want to guard
func init() {
extension.SetFilter(SentinelProviderFilterName, GetSentinelProviderFilter)
extension.SetFilter(SentinelConsumerFilterName, GetSentinelConsumerFilter)
if err := sentinel.InitDefault(); err != nil {
logger.Errorf("[Sentinel Filter] fail to initialize Sentinel")
}
if err := logging.ResetGlobalLogger(DubboLoggerWrapper{Logger: logger.GetLogger()}); err != nil {
logger.Errorf("[Sentinel Filter] fail to ingest dubbo logger into sentinel")
}
......@@ -54,20 +55,36 @@ type DubboLoggerWrapper struct {
logger.Logger
}
func (d DubboLoggerWrapper) Fatal(v ...interface{}) {
d.Logger.Error(v...)
func (d DubboLoggerWrapper) Debug(msg string, keysAndValues ...interface{}) {
d.Logger.Debug(logging.AssembleMsg(logging.GlobalCallerDepth, "DEBUG", msg, nil, keysAndValues))
}
func (d DubboLoggerWrapper) DebugEnabled() bool {
return true
}
func (d DubboLoggerWrapper) Fatalf(format string, v ...interface{}) {
d.Logger.Errorf(format, v...)
func (d DubboLoggerWrapper) Info(msg string, keysAndValues ...interface{}) {
d.Logger.Info(logging.AssembleMsg(logging.GlobalCallerDepth, "INFO", msg, nil, keysAndValues))
}
func (d DubboLoggerWrapper) InfoEnabled() bool {
return true
}
func (d DubboLoggerWrapper) Panic(v ...interface{}) {
d.Logger.Error(v...)
func (d DubboLoggerWrapper) Warn(msg string, keysAndValues ...interface{}) {
d.Logger.Warn(logging.AssembleMsg(logging.GlobalCallerDepth, "WARN", msg, nil, keysAndValues))
}
func (d DubboLoggerWrapper) Panicf(format string, v ...interface{}) {
d.Logger.Errorf(format, v...)
func (d DubboLoggerWrapper) WarnEnabled() bool {
return true
}
func (d DubboLoggerWrapper) Error(err error, msg string, keysAndValues ...interface{}) {
d.Logger.Warn(logging.AssembleMsg(logging.GlobalCallerDepth, "ERROR", msg, err, keysAndValues))
}
func (d DubboLoggerWrapper) ErrorEnabled() bool {
return true
}
func GetSentinelConsumerFilter() filter.Filter {
......
......@@ -83,7 +83,7 @@ func (tf *tracingFilter) Invoke(ctx context.Context, invoker protocol.Invoker, i
}()
result := invoker.Invoke(spanCtx, invocation)
span.SetTag(successKey, result.Error() != nil)
span.SetTag(successKey, result.Error() == nil)
if result.Error() != nil {
span.LogFields(log.String(errorKey, result.Error().Error()))
}
......
......@@ -5,7 +5,7 @@ require (
github.com/RoaringBitmap/roaring v0.5.5
github.com/Workiva/go-datastructures v1.0.52
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/alibaba/sentinel-golang v0.6.2
github.com/alibaba/sentinel-golang v1.0.1
github.com/apache/dubbo-getty v1.3.10
github.com/apache/dubbo-go-hessian2 v1.7.0
github.com/coreos/etcd v3.3.25+incompatible
......@@ -39,6 +39,7 @@ require (
github.com/stretchr/objx v0.2.0 // indirect
github.com/stretchr/testify v1.6.1
github.com/zouyx/agollo/v3 v3.4.5
go.etcd.io/bbolt v1.3.5 // indirect
go.uber.org/atomic v1.7.0
go.uber.org/zap v1.16.0
google.golang.org/grpc v1.26.0
......
This diff is collapsed.
......@@ -25,6 +25,8 @@ import (
type Invocation interface {
// MethodName gets invocation method name.
MethodName() string
// ParameterTypeNames gets invocation parameter type names.
ParameterTypeNames() []string
// ParameterTypes gets invocation parameter types.
ParameterTypes() []reflect.Type
// ParameterValues gets invocation parameter values.
......
......@@ -35,8 +35,11 @@ import (
// todo: is it necessary to separate fields of consumer(provider) from RPCInvocation
// nolint
type RPCInvocation struct {
methodName string
parameterTypes []reflect.Type
methodName string
// Parameter Type Names. It is used to specify the parameterType
parameterTypeNames []string
parameterTypes []reflect.Type
parameterValues []reflect.Value
arguments []interface{}
reply interface{}
......@@ -80,6 +83,11 @@ func (r *RPCInvocation) ParameterTypes() []reflect.Type {
return r.parameterTypes
}
// ParameterTypeNames gets RPC invocation parameter types of string expression.
func (r *RPCInvocation) ParameterTypeNames() []string {
return r.parameterTypeNames
}
// ParameterValues gets RPC invocation parameter values.
func (r *RPCInvocation) ParameterValues() []reflect.Value {
return r.parameterValues
......@@ -213,6 +221,18 @@ func WithParameterTypes(parameterTypes []reflect.Type) option {
}
}
// WithParameterTypeNames creates option with @parameterTypeNames.
func WithParameterTypeNames(parameterTypeNames []string) option {
return func(invo *RPCInvocation) {
if len(parameterTypeNames) == 0 {
return
}
parameterTypeNamesTmp := make([]string, len(parameterTypeNames))
copy(parameterTypeNamesTmp, parameterTypeNames)
invo.parameterTypeNames = parameterTypeNamesTmp
}
}
// WithParameterValues creates option with @parameterValues
func WithParameterValues(parameterValues []reflect.Value) option {
return func(invo *RPCInvocation) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment