AlexStocks commented on a change in pull request #493: URL: https://github.com/apache/dubbo-go/pull/493#discussion_r415105723
########## File path: registry/eureka/service_discovery.go ########## @@ -0,0 +1,205 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package eureka + +import ( + "fmt" + "net" + "strings" +) + +import ( + gxset "github.com/dubbogo/gost/container/set" + gxpage "github.com/dubbogo/gost/page" + "github.com/hudl/fargo" + perrors "github.com/pkg/errors" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/registry" +) + +// init will put the service discovery into extension +func init() { + extension.SetServiceDiscovery(constant.EUREKA_KEY, newEurekaServiceDiscovery) +} + +// eurekaServiceDiscovery is the implementation of service discovery based on eureka. +type eurekaServiceDiscovery struct { + eurekaConnection *fargo.EurekaConnection + group string + *common.URL +} + +// toDeregisterInstance will convert the ServiceInstance to DeregisterInstanceParam +func (e *eurekaServiceDiscovery) toDeregisterInstance(instance registry.ServiceInstance) *fargo.Instance { + return &fargo.Instance{ + HomePageUrl: instance.GetServiceName(), + IPAddr: instance.GetHost(), + Port: instance.GetPort(), + App: e.group, + } +} + +// Destroy will close the service discovery. +// Actually, it only marks the eurekaConnection as null and then return +func (e *eurekaServiceDiscovery) Destroy() error { + e.eurekaConnection = nil Review comment: do u think u really do not need a lock here? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
