AlexStocks commented on a change in pull request #1161: URL: https://github.com/apache/dubbo-go/pull/1161#discussion_r615306537
########## File path: metadata/remote/impl/service.go ########## @@ -0,0 +1,151 @@ +/* + * 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 impl + +import ( + "github.com/apache/dubbo-go/common/extension" + "github.com/apache/dubbo-go/metadata/remote" + "github.com/apache/dubbo-go/registry" + "sync" +) + +import ( + "go.uber.org/atomic" +) + +import ( + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/common/constant" + "github.com/apache/dubbo-go/common/logger" + "github.com/apache/dubbo-go/metadata/definition" + "github.com/apache/dubbo-go/metadata/identifier" + "github.com/apache/dubbo-go/metadata/report/delegate" + "github.com/apache/dubbo-go/metadata/service/inmemory" +) + +// version will be used by Version func +const ( + version = "1.0.0" + remoteKey = "remote" +) + +// MetadataService is a implement of metadata service which will delegate the remote metadata report +// This is singleton +type RemoteMetadataServiceImpl struct { + *inmemory.MetadataService + exportedRevision atomic.String + subscribedRevision atomic.String + delegateReport *delegate.MetadataReport +} + +var ( + metadataServiceOnce sync.Once + remoteMetadataServiceImplInstance remote.RemoteMetadataService +) + +func init() { + extension.SetMetadataRemoteService(GetRemoteMetadataService) +} + +// GetRemoteMetadataService will create a new remote MetadataService instance +func GetRemoteMetadataService() (remote.RemoteMetadataService, error) { + var err error + metadataServiceOnce.Do(func() { + var mr *delegate.MetadataReport + mr, err = delegate.NewMetadataReport() + if err != nil { + return + } + // it will never return error + inms, _ := inmemory.GetInMemoryMetadataService() + remoteMetadataServiceImplInstance = &RemoteMetadataServiceImpl{ + // todo serviceName + //BaseMetadataService: service.NewBaseMetadataService(""), + MetadataService: inms.(*inmemory.MetadataService), + delegateReport: mr, + } + }) + return remoteMetadataServiceImplInstance, err +} + +// PublishMetadata publish the medata info of service from report Review comment: // PublishMetadata publishes the metadata info of @service to remote metadata center -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
