-
Notifications
You must be signed in to change notification settings - Fork 929
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add protobuf based MetadataService support (#2723)
- Loading branch information
Showing
47 changed files
with
2,010 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* 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 extension | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
import ( | ||
"dubbo.apache.org/dubbo-go/v3/common/constant" | ||
"dubbo.apache.org/dubbo-go/v3/metadata/service" | ||
) | ||
|
||
var metadataServiceProxyFactoryMapV2 = make(map[string]func() service.MetadataServiceProxyFactoryV2, 2) | ||
|
||
type MetadataServiceProxyFactoryFuncV2 func() service.MetadataServiceProxyFactoryV2 | ||
|
||
// SetMetadataServiceProxyFactory store the name-creator pair | ||
func SetMetadataServiceProxyFactoryV2(name string, creator MetadataServiceProxyFactoryFuncV2) { | ||
metadataServiceProxyFactoryMapV2[name] = creator | ||
} | ||
|
||
// GetMetadataServiceProxyFactory will create an instance. | ||
// it will panic if the factory with name not found | ||
func GetMetadataServiceProxyFactoryV2(name string) service.MetadataServiceProxyFactoryV2 { | ||
if name == "" { | ||
name = constant.DefaultKey | ||
} | ||
if f, ok := metadataServiceProxyFactoryMapV2[name]; ok { | ||
return f() | ||
} | ||
panic(fmt.Sprintf("could not find the metadata service factory creator for name: %s, "+ | ||
"please check whether you have imported relative packages, "+ | ||
"local - dubbo.apache.org/dubbo-go/v3/metadata/service/local", name)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 extension | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
import ( | ||
perrors "github.com/pkg/errors" | ||
) | ||
|
||
import ( | ||
"dubbo.apache.org/dubbo-go/v3/common/constant" | ||
"dubbo.apache.org/dubbo-go/v3/metadata/service" | ||
) | ||
|
||
type localMetadataServiceCreatorV1 func() (service.MetadataServiceV1, error) | ||
|
||
var ( | ||
localMetadataServiceInsMapV1 = make(map[string]localMetadataServiceCreatorV1, 2) | ||
) | ||
|
||
// SetLocalMetadataService will store the msType => creator pair | ||
func SetLocalMetadataServiceV1(key string, creator localMetadataServiceCreatorV1) { | ||
localMetadataServiceInsMapV1[key] = creator | ||
} | ||
|
||
// GetLocalMetadataService will create a local MetadataService instance | ||
func GetLocalMetadataServiceV1(key string) (service.MetadataServiceV1, error) { | ||
if key == "" { | ||
key = constant.DefaultKey | ||
} | ||
if creator, ok := localMetadataServiceInsMapV1[key]; ok { | ||
return creator() | ||
} | ||
return nil, perrors.New(fmt.Sprintf("could not find the metadata service creator for metadataType: local, " + | ||
"please check whether you have imported relative packages, " + | ||
"local - dubbo.apache.org/dubbo-go/v3/metadata/service/local")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 extension | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
import ( | ||
perrors "github.com/pkg/errors" | ||
) | ||
|
||
import ( | ||
"dubbo.apache.org/dubbo-go/v3/common/constant" | ||
"dubbo.apache.org/dubbo-go/v3/metadata/service" | ||
) | ||
|
||
type localMetadataServiceCreatorV2 func() (service.MetadataServiceV2, error) | ||
|
||
var ( | ||
localMetadataServiceInsMapV2 = make(map[string]localMetadataServiceCreatorV2, 2) | ||
) | ||
|
||
// SetLocalMetadataService will store the msType => creator pair | ||
func SetLocalMetadataServiceV2(key string, creator localMetadataServiceCreatorV2) { | ||
localMetadataServiceInsMapV2[key] = creator | ||
} | ||
|
||
// GetLocalMetadataService will create a local MetadataService instance | ||
func GetLocalMetadataServiceV2(key string) (service.MetadataServiceV2, error) { | ||
if key == "" { | ||
key = constant.DefaultKey | ||
} | ||
if creator, ok := localMetadataServiceInsMapV2[key]; ok { | ||
return creator() | ||
} | ||
return nil, perrors.New(fmt.Sprintf("could not find the metadata service creator for metadataType: local, " + | ||
"please check whether you have imported relative packages, " + | ||
"local - dubbo.apache.org/dubbo-go/v3/metadata/service/local")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.