This is an automated email from the ASF dual-hosted git repository.
Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new d44bc1894 [FEAT] delete synthesizer logic (#3360)
d44bc1894 is described below
commit d44bc18940bdc9ba38c739af5d363dac5547efd7
Author: Xuetao Li <[email protected]>
AuthorDate: Thu Jun 11 17:37:13 2026 +0800
[FEAT] delete synthesizer logic (#3360)
* delete synthesizer logic
* Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI
<[email protected]>
---------
Co-authored-by: Copilot Autofix powered by AI
<[email protected]>
---
cluster/router/chain/chain.go | 2 +-
protocol/rest/config/reader/rest_config_reader.go | 6 +-
.../rest/rest_subscribed_urls_synthesizer.go | 61 ------------------
.../rest/rest_subscribed_urls_synthesizer_test.go | 75 ----------------------
.../synthesizer/subscribed_urls_synthesizer.go | 31 ---------
.../subscribed_urls_synthesizer_factory.go | 41 ------------
6 files changed, 3 insertions(+), 213 deletions(-)
diff --git a/cluster/router/chain/chain.go b/cluster/router/chain/chain.go
index adbc7a74b..c2ad25b40 100644
--- a/cluster/router/chain/chain.go
+++ b/cluster/router/chain/chain.go
@@ -205,7 +205,7 @@ func NewRouterChain(url *common.URL) (*RouterChain, error) {
routerFactories := extension.GetRouterFactories()
if len(routerFactories) == 0 {
- return nil, perrors.Errorf("No routerFactory exits , create one
please")
+ return nil, perrors.Errorf("No routerFactory exists, create one
please")
}
routers := make([]router.PriorityRouter, 0, len(routerFactories))
diff --git a/protocol/rest/config/reader/rest_config_reader.go
b/protocol/rest/config/reader/rest_config_reader.go
index a6bb6305a..c052d6721 100644
--- a/protocol/rest/config/reader/rest_config_reader.go
+++ b/protocol/rest/config/reader/rest_config_reader.go
@@ -38,11 +38,9 @@ import (
"dubbo.apache.org/dubbo-go/v3/protocol/rest/config"
)
-const REST = "rest"
-
func init() {
- extension.SetConfigReaders(REST, NewRestConfigReader)
- extension.SetDefaultConfigReader(REST, REST)
+ extension.SetConfigReaders(constant.RESTProtocol, NewRestConfigReader)
+ extension.SetDefaultConfigReader(constant.RESTProtocol,
constant.RESTProtocol)
}
type RestConfigReader struct{}
diff --git
a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
deleted file mode 100644
index 438f29a0c..000000000
---
a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer.go
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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 rest
-
-import (
- "net/url"
- "strings"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/common"
- "dubbo.apache.org/dubbo-go/v3/common/constant"
- "dubbo.apache.org/dubbo-go/v3/registry"
- "dubbo.apache.org/dubbo-go/v3/registry/servicediscovery/synthesizer"
-)
-
-func init() {
- synthesizer.AddSynthesizer(NewRestSubscribedURLsSynthesizer())
-}
-
-// SubscribedURLsSynthesizer implementation for rest protocol
-type RestSubscribedURLsSynthesizer struct{}
-
-func (r RestSubscribedURLsSynthesizer) Support(subscribedURL *common.URL) bool
{
- return subscribedURL.Protocol == "rest"
-}
-
-func (r RestSubscribedURLsSynthesizer) Synthesize(subscribedURL *common.URL,
serviceInstances []registry.ServiceInstance) []*common.URL {
- urls := make([]*common.URL, len(serviceInstances))
- for i, s := range serviceInstances {
- splitHost := strings.Split(s.GetHost(), ":")
- u :=
common.NewURLWithOptions(common.WithProtocol(subscribedURL.Protocol),
common.WithIp(splitHost[0]),
- common.WithPort(splitHost[1]),
common.WithPath(subscribedURL.GetParam(constant.InterfaceKey,
subscribedURL.Path)),
- common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SideKey,
constant.ProviderProtocol),
- common.WithParamsValue(constant.ApplicationKey,
s.GetServiceName()),
- common.WithParamsValue(constant.RegistryKey, "true"),
- )
- urls[i] = u
- }
- return urls
-}
-
-func NewRestSubscribedURLsSynthesizer() RestSubscribedURLsSynthesizer {
- return RestSubscribedURLsSynthesizer{}
-}
diff --git
a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
b/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
deleted file mode 100644
index 5d809a4e7..000000000
---
a/registry/servicediscovery/synthesizer/rest/rest_subscribed_urls_synthesizer_test.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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 rest
-
-import (
- "net/url"
- "testing"
-)
-
-import (
- "github.com/stretchr/testify/assert"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/common"
- "dubbo.apache.org/dubbo-go/v3/common/constant"
- "dubbo.apache.org/dubbo-go/v3/registry"
-)
-
-func TestRestSubscribedURLsSynthesizer_Synthesize(t *testing.T) {
- syn := RestSubscribedURLsSynthesizer{}
- subUrl, _ :=
common.NewURL("rest://127.0.0.1:20000/org.apache.dubbo-go.mockService")
- instances := []registry.ServiceInstance{
- ®istry.DefaultServiceInstance{
- ID: "test1",
- ServiceName: "test1",
- Host: "127.0.0.1:80",
- Port: 80,
- Enable: false,
- Healthy: false,
- Metadata: nil,
- },
- ®istry.DefaultServiceInstance{
- ID: "test2",
- ServiceName: "test2",
- Host: "127.0.0.2:8081",
- Port: 8081,
- Enable: false,
- Healthy: false,
- Metadata: nil,
- },
- }
-
- var expectUrls []*common.URL
- u1 := common.NewURLWithOptions(common.WithProtocol("rest"),
common.WithIp("127.0.0.1"),
- common.WithPort("80"),
common.WithPath("org.apache.dubbo-go.mockService"),
- common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SideKey,
constant.ProviderProtocol),
- common.WithParamsValue(constant.ApplicationKey, "test1"),
- common.WithParamsValue(constant.RegistryKey, "true"))
- u2 := common.NewURLWithOptions(common.WithProtocol("rest"),
common.WithIp("127.0.0.2"),
- common.WithPort("8081"),
common.WithPath("org.apache.dubbo-go.mockService"),
- common.WithParams(url.Values{}),
- common.WithParamsValue(constant.SideKey,
constant.ProviderProtocol),
- common.WithParamsValue(constant.ApplicationKey, "test2"),
- common.WithParamsValue(constant.RegistryKey, "true"))
- expectUrls = append(expectUrls, u1, u2)
- result := syn.Synthesize(subUrl, instances)
- assert.Equal(t, expectUrls, result)
-}
diff --git
a/registry/servicediscovery/synthesizer/subscribed_urls_synthesizer.go
b/registry/servicediscovery/synthesizer/subscribed_urls_synthesizer.go
deleted file mode 100644
index 76a373055..000000000
--- a/registry/servicediscovery/synthesizer/subscribed_urls_synthesizer.go
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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 synthesizer
-
-import (
- "dubbo.apache.org/dubbo-go/v3/common"
- "dubbo.apache.org/dubbo-go/v3/registry"
-)
-
-// SubscribedURLsSynthesizer is used to synthesize the subscribed url
-type SubscribedURLsSynthesizer interface {
- // Supports the synthesis of the subscribed url or not
- Support(subscribedURL *common.URL) bool
- // synthesize the subscribed url
- Synthesize(subscribedURL *common.URL, serviceInstances
[]registry.ServiceInstance) []*common.URL
-}
diff --git
a/registry/servicediscovery/synthesizer/subscribed_urls_synthesizer_factory.go
b/registry/servicediscovery/synthesizer/subscribed_urls_synthesizer_factory.go
deleted file mode 100644
index 716291456..000000000
---
a/registry/servicediscovery/synthesizer/subscribed_urls_synthesizer_factory.go
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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 synthesizer
-
-import (
- "sync"
-)
-
-var (
- synthesizers []SubscribedURLsSynthesizer
- synthesizerMutex sync.RWMutex
-)
-
-// AddSynthesizer registers a SubscribedURLsSynthesizer into the factory list.
-func AddSynthesizer(synthesizer SubscribedURLsSynthesizer) {
- synthesizerMutex.Lock()
- defer synthesizerMutex.Unlock()
- synthesizers = append(synthesizers, synthesizer)
-}
-
-// GetAllSynthesizer returns all registered SubscribedURLsSynthesizer.
-func GetAllSynthesizer() []SubscribedURLsSynthesizer {
- synthesizerMutex.RLock()
- defer synthesizerMutex.RUnlock()
- return synthesizers
-}