Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
dabfdedb
Commit
dabfdedb
authored
5 years ago
by
renzhiyuan
Committed by
aliiohs
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add GetBackupUrls method
parent
7b07c345
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
cluster/router_chain.go
+16
-16
16 additions, 16 deletions
cluster/router_chain.go
common/constant/key.go
+1
-0
1 addition, 0 deletions
common/constant/key.go
common/url.go
+22
-0
22 additions, 0 deletions
common/url.go
registry/directory/directory.go
+7
-2
7 additions, 2 deletions
registry/directory/directory.go
with
46 additions
and
18 deletions
cluster/router_chain.go
+
16
−
16
View file @
dabfdedb
...
...
@@ -2,7 +2,6 @@ package cluster
import
(
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/common/extension"
"github.com/apache/dubbo-go/protocol"
"sort"
)
...
...
@@ -14,21 +13,22 @@ type RouterChain struct {
}
func
NewRouterChain
(
url
common
.
URL
)
*
RouterChain
{
var
builtinRouters
[]
Router
factories
:=
extension
.
GetRouterFactorys
()
for
_
,
factory
:=
range
factories
{
router
,
_
:=
factory
.
Router
(
&
url
)
builtinRouters
=
append
(
builtinRouters
,
router
)
}
var
routers
[]
Router
copy
(
routers
,
builtinRouters
)
sort
.
Slice
(
routers
,
func
(
i
,
j
int
)
bool
{
return
routers
[
i
]
.
Priority
()
<
routers
[
j
]
.
Priority
()
})
return
&
RouterChain
{
builtinRouters
:
routers
,
routers
:
routers
,
}
//var builtinRouters []Router
//factories := extension.GetRouterFactories()
//for _, factory := range factories {
// router, _ := factory.Router(&url)
// builtinRouters = append(builtinRouters, router)
//}
//var routers []Router
//copy(routers, builtinRouters)
//sort.Slice(routers, func(i, j int) bool {
// return routers[i].Priority() < routers[j].Priority()
//})
//return &RouterChain{
// builtinRouters: routers,
// routers: routers,
//}
return
nil
}
func
(
r
RouterChain
)
AddRouters
(
routers
[]
Router
)
{
...
...
This diff is collapsed.
Click to expand it.
common/constant/key.go
+
1
−
0
View file @
dabfdedb
...
...
@@ -74,6 +74,7 @@ const (
METHOD_KEYS
=
"methods"
RULE_KEY
=
"rule"
RUNTIME_KEY
=
"runtime"
BACKUP_KEY
=
"backup"
)
const
(
...
...
This diff is collapsed.
Click to expand it.
common/url.go
+
22
−
0
View file @
dabfdedb
...
...
@@ -242,6 +242,28 @@ func (c URL) Key() string {
//return c.ServiceKey()
}
//todo
func
(
c
URL
)
GetBackupUrls
()
[]
URL
{
var
urls
[]
URL
var
host
string
urls
=
append
(
urls
,
c
)
backups
:=
strings
.
Split
(
c
.
GetParam
(
constant
.
BACKUP_KEY
,
""
),
""
)
for
_
,
address
:=
range
backups
{
index
:=
strings
.
LastIndex
(
address
,
":"
)
port
:=
c
.
Port
if
index
>
0
{
host
=
address
[
:
index
]
port
=
address
[
index
+
1
:
]
}
else
{
host
=
string
(
append
([]
byte
(
host
),
[]
byte
(
port
)
...
))
}
//todo
newURL
,
_
:=
NewURL
(
c
.
ctx
,
address
)
urls
=
append
(
urls
,
newURL
)
}
return
urls
}
func
(
c
URL
)
ServiceKey
()
string
{
intf
:=
c
.
GetParam
(
constant
.
INTERFACE_KEY
,
strings
.
TrimPrefix
(
c
.
Path
,
"/"
))
if
intf
==
""
{
...
...
This diff is collapsed.
Click to expand it.
registry/directory/directory.go
+
7
−
2
View file @
dabfdedb
...
...
@@ -19,8 +19,6 @@ package directory
import
(
"fmt"
"github.com/apache/dubbo-go/common/utils"
"github.com/apache/dubbo-go/version"
"reflect"
"sync"
"time"
...
...
@@ -37,10 +35,12 @@ import (
"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/common/utils"
"github.com/apache/dubbo-go/protocol"
"github.com/apache/dubbo-go/protocol/protocolwrapper"
"github.com/apache/dubbo-go/registry"
"github.com/apache/dubbo-go/remoting"
"github.com/apache/dubbo-go/version"
)
const
(
...
...
@@ -131,7 +131,11 @@ func (dir *registryDirectory) update(res *registry.ServiceEvent) {
logger
.
Debugf
(
"registry update, result{%s}"
,
res
)
logger
.
Debugf
(
"update service name: %s!"
,
res
.
Service
)
//todo
_
=
dir
.
GetUrl
()
if
len
(
dir
.
Routers
())
>
0
{
}
dir
.
refreshInvokers
(
res
)
}
...
...
@@ -228,6 +232,7 @@ func (dir *registryDirectory) List(invocation protocol.Invocation) ([]protocol.I
localRouters
:=
dir
.
Routers
()
if
len
(
localRouters
)
>
0
{
for
_
,
router
:=
range
localRouters
{
//todo nil error
if
reflect
.
ValueOf
(
router
.
Url
())
.
IsNil
()
||
router
.
Url
()
.
GetParamBool
(
constant
.
RUNTIME_KEY
,
false
)
{
invokers
=
router
.
Route
(
invokers
,
*
dir
.
ConsumerUrl
,
invocation
)
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment