Skip to content
Snippets Groups Projects
Commit 24cb5127 authored by flycash's avatar flycash
Browse files

Fix Review

parent f2571410
No related branches found
No related tags found
No related merge requests found
......@@ -26,7 +26,7 @@ import (
)
var (
metadataServiceProxyFactoryMap = make(map[string]func() service.MetadataServiceProxyFactory)
metadataServiceProxyFactoryMap = make(map[string]func() service.MetadataServiceProxyFactory, 2)
)
type MetadataServiceProxyFactoryFunc func() service.MetadataServiceProxyFactory
......
......@@ -26,7 +26,7 @@ import (
)
var (
serviceInstanceSelectorMappings = make(map[string]func() instance.ServiceInstanceSelector)
serviceInstanceSelectorMappings = make(map[string]func() instance.ServiceInstanceSelector, 2)
)
// nolint
......
......@@ -21,11 +21,13 @@ import (
"github.com/apache/dubbo-go/metadata/mapping"
)
type ServiceNameMappingCreator func() mapping.ServiceNameMapping
var (
globalNameMappingCreator func() mapping.ServiceNameMapping
globalNameMappingCreator ServiceNameMappingCreator
)
func SetGlobalServiceNameMapping(nameMappingCreator func() mapping.ServiceNameMapping) {
func SetGlobalServiceNameMapping(nameMappingCreator ServiceNameMappingCreator) {
globalNameMappingCreator = nameMappingCreator
}
......
......@@ -110,7 +110,7 @@ func (bl *BaseListener) RemoveEventListeners(listenersSlice []EventListener) {
func (bl *BaseListener) RemoveAllEventListeners() {
bl.Mutex.Lock()
defer bl.Mutex.Unlock()
bl.ListenersCache = make(map[reflect.Type][]EventListener)
bl.ListenersCache = make(map[reflect.Type][]EventListener, 8)
}
// GetAllEventListeners get all listener
......
......@@ -196,20 +196,12 @@ func (mts *MetadataService) PublishServiceDefinition(url common.URL) error {
interfaceName := url.GetParam(constant.INTERFACE_KEY, "")
isGeneric := url.GetParamBool(constant.GENERIC_KEY, false)
if len(interfaceName) > 0 && !isGeneric {
// judge is consumer or provider
// side := url.GetParam(constant.SIDE_KEY, "")
// var service event.RPCService
service := common.ServiceMap.GetService(url.Protocol, url.GetParam(constant.BEAN_NAME_KEY, url.Service()))
// if side == event.RoleType(event.CONSUMER).Role() {
// //TODO:generate the service definition and store it
//
// } else if side == event.RoleType(event.PROVIDER).Role() {
// //TODO:generate the service definition and store it
// }
sd := definition.BuildServiceDefinition(*service, url)
data, err := sd.ToBytes()
if err != nil {
logger.Errorf("publishProvider getServiceDescriptor error. providerUrl:%v , error:%v ", url, err)
return nil
}
mts.serviceDefinitions.Store(url.ServiceKey(), string(data))
return nil
......
......@@ -101,6 +101,6 @@ func endpointsStr(protocolMap map[string]int) string {
// nolint
type endpoint struct {
Port int `json:"port"`
Protocol string `json:"protocol"`
Port int `json:"port, omitempty"`
Protocol string `json:"protocol, omitempty"`
}
......@@ -95,7 +95,7 @@ func newServiceDiscoveryRegistry(url *common.URL) (registry.Registry, error) {
subscribedServices: subscribedServices,
subscribedURLsSynthesizers: subscribedURLsSynthesizers,
registeredListeners: gxset.NewSet(),
serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL),
serviceRevisionExportedURLsCache: make(map[string]map[string][]common.URL, 8),
serviceNameMapping: serviceNameMapping,
metaDataService: metaDataService,
}, nil
......@@ -316,7 +316,6 @@ func (s *serviceDiscoveryRegistry) subscribe(url *common.URL, notify registry.No
if len(subscribedURLs) == 0 {
subscribedURLs = s.synthesizeSubscribedURLs(url, serviceInstances)
}
// TODO make sure it's workable
for _, url := range subscribedURLs {
notify.Notify(&registry.ServiceEvent{
Action: remoting.EventTypeAdd,
......@@ -519,7 +518,7 @@ func (s *serviceDiscoveryRegistry) initRevisionExportedURLsByInst(serviceInstanc
revision := getExportedServicesRevision(serviceInstance)
revisionExportedURLsMap := s.serviceRevisionExportedURLsCache[serviceName]
if revisionExportedURLsMap == nil {
revisionExportedURLsMap = make(map[string][]common.URL)
revisionExportedURLsMap = make(map[string][]common.URL, 4)
s.serviceRevisionExportedURLsCache[serviceName] = revisionExportedURLsMap
}
revisionExportedURLs := revisionExportedURLsMap[revision]
......@@ -592,8 +591,8 @@ func (s *serviceDiscoveryRegistry) cloneExportedURLs(url common.URL, serviceInsa
}
type endpoint struct {
Port int `json:"port"`
Protocol string `json:"protocol"`
Port int `json:"port, omitempty"`
Protocol string `json:"protocol, omitempty"`
}
func getProtocolPort(serviceInstance registry.ServiceInstance, protocol string) int {
......
......@@ -308,7 +308,7 @@ func (zksd *zookeeperServiceDiscovery) DataChange(eventType remoting.Event) bool
// toCuratorInstance convert to curator's service instance
func (zksd *zookeeperServiceDiscovery) toCuratorInstance(instance registry.ServiceInstance) *curator_discovery.ServiceInstance {
id := instance.GetHost() + ":" + strconv.Itoa(instance.GetPort())
pl := make(map[string]interface{})
pl := make(map[string]interface{}, 8)
pl["id"] = id
pl["name"] = instance.GetServiceName()
pl["metadata"] = instance.GetMetadata()
......
......@@ -169,6 +169,7 @@ type Client struct {
Wait sync.WaitGroup
}
// nolint
func NewClient(name string, endpoints []string, timeout time.Duration, heartbeat int) (*Client, error) {
ctx, cancel := context.WithCancel(context.Background())
......
......@@ -163,6 +163,8 @@ func ValidateZookeeperClient(container ZkClientFacade, opts ...Option) error {
return perrors.WithMessagef(err, "newZookeeperClient(address:%+v)", url.PrimitiveURL)
}
// nolint
func NewZookeeperClient(name string, zkAddrs []string, timeout time.Duration) (*ZookeeperClient, error) {
var (
err error
......@@ -634,7 +636,7 @@ func (z *ZookeeperClient) GetContent(zkPath string) ([]byte, *zk.Stat, error) {
return z.Conn.Get(zkPath)
}
// GetContent ...
// nolint
func (z *ZookeeperClient) SetContent(zkPath string, content []byte, version int32) (*zk.Stat, error) {
return z.Conn.Set(zkPath, content, version)
}
......
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