Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
1a4aa2eb
Unverified
Commit
1a4aa2eb
authored
Nov 01, 2023
by
Danyal Prout
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Review feedback
parent
3b232e74
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
backend.go
proxyd/backend.go
+7
-7
config.go
proxyd/config.go
+3
-3
proxyd.go
proxyd/proxyd.go
+3
-3
No files found.
proxyd/backend.go
View file @
1a4aa2eb
...
...
@@ -691,10 +691,10 @@ func sortBatchRPCResponse(req []*RPCReq, res []*RPCRes) {
}
type
BackendGroup
struct
{
Name
string
Backends
[]
*
Backend
Use
WeightedRouting
bool
Consensus
*
ConsensusPoller
Name
string
Backends
[]
*
Backend
WeightedRouting
bool
Consensus
*
ConsensusPoller
}
func
(
bg
*
BackendGroup
)
Forward
(
ctx
context
.
Context
,
rpcReqs
[]
*
RPCReq
,
isBatch
bool
)
([]
*
RPCRes
,
string
,
error
)
{
...
...
@@ -750,7 +750,7 @@ func (bg *BackendGroup) Forward(ctx context.Context, rpcReqs []*RPCReq, isBatch
}
}
rpcReqs
=
rewrittenReqs
}
else
if
bg
.
Use
WeightedRouting
{
}
else
if
bg
.
WeightedRouting
{
backends
=
randomizeFirstBackendByWeight
(
backends
)
}
...
...
@@ -820,7 +820,7 @@ func (bg *BackendGroup) Forward(ctx context.Context, rpcReqs []*RPCReq, isBatch
}
func
randomizeFirstBackendByWeight
(
backends
[]
*
Backend
)
[]
*
Backend
{
if
len
(
backends
)
==
0
{
if
len
(
backends
)
<=
1
{
return
backends
}
...
...
@@ -916,7 +916,7 @@ func (bg *BackendGroup) loadBalancedConsensusGroup() []*Backend {
backendsDegraded
[
i
],
backendsDegraded
[
j
]
=
backendsDegraded
[
j
],
backendsDegraded
[
i
]
})
if
bg
.
Use
WeightedRouting
{
if
bg
.
WeightedRouting
{
backendsHealthy
=
randomizeFirstBackendByWeight
(
backendsHealthy
)
backendsDegraded
=
randomizeFirstBackendByWeight
(
backendsDegraded
)
}
...
...
proxyd/config.go
View file @
1a4aa2eb
...
...
@@ -95,11 +95,11 @@ type BackendConfig struct {
ClientKeyFile
string
`toml:"client_key_file"`
StripTrailingXFF
bool
`toml:"strip_trailing_xff"`
Weight
int
`toml:"weight"`
ConsensusSkipPeerCountCheck
bool
`toml:"consensus_skip_peer_count"`
ConsensusForcedCandidate
bool
`toml:"consensus_forced_candidate"`
ConsensusReceiptsTarget
string
`toml:"consensus_receipts_target"`
Weight
int
`toml:"weight"`
}
type
BackendsConfig
map
[
string
]
*
BackendConfig
...
...
@@ -107,7 +107,7 @@ type BackendsConfig map[string]*BackendConfig
type
BackendGroupConfig
struct
{
Backends
[]
string
`toml:"backends"`
Use
WeightedRouting
bool
`toml:"weighted_routing"`
WeightedRouting
bool
`toml:"weighted_routing"`
ConsensusAware
bool
`toml:"consensus_aware"`
ConsensusAsyncHandler
string
`toml:"consensus_handler"`
...
...
proxyd/proxyd.go
View file @
1a4aa2eb
...
...
@@ -176,9 +176,9 @@ func Start(config *Config) (*Server, func(), error) {
backends
=
append
(
backends
,
backendsByName
[
bName
])
}
group
:=
&
BackendGroup
{
Name
:
bgName
,
UseWeightedRouting
:
bg
.
Use
WeightedRouting
,
Backends
:
backends
,
Name
:
bgName
,
WeightedRouting
:
bg
.
WeightedRouting
,
Backends
:
backends
,
}
backendGroups
[
bgName
]
=
group
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment