Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
c0f62e3f
Commit
c0f62e3f
authored
Aug 10, 2017
by
Yong Tang
Committed by
GitHub
Aug 10, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go lint cleanup (#891)
Signed-off-by:
Yong Tang
<
yong.tang.github@outlook.com
>
parent
26d8680a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
middleware/pkg/healthcheck/healthcheck.go
middleware/pkg/healthcheck/healthcheck.go
+8
-2
middleware/pkg/healthcheck/policy.go
middleware/pkg/healthcheck/policy.go
+1
-0
No files found.
middleware/pkg/healthcheck/healthcheck.go
View file @
c0f62e3f
...
@@ -55,6 +55,9 @@ func (uh *UpstreamHost) Down() bool {
...
@@ -55,6 +55,9 @@ func (uh *UpstreamHost) Down() bool {
// HostPool is a collection of UpstreamHosts.
// HostPool is a collection of UpstreamHosts.
type
HostPool
[]
*
UpstreamHost
type
HostPool
[]
*
UpstreamHost
// HealthCheck is used for performing healthcheck
// on a collection of upstream hosts and select
// one based on the policy.
type
HealthCheck
struct
{
type
HealthCheck
struct
{
wg
sync
.
WaitGroup
// Used to wait for running goroutines to stop.
wg
sync
.
WaitGroup
// Used to wait for running goroutines to stop.
stop
chan
struct
{}
// Signals running goroutines to stop.
stop
chan
struct
{}
// Signals running goroutines to stop.
...
@@ -69,13 +72,14 @@ type HealthCheck struct {
...
@@ -69,13 +72,14 @@ type HealthCheck struct {
Interval
time
.
Duration
Interval
time
.
Duration
}
}
// Start starts the healthcheck
func
(
u
*
HealthCheck
)
Start
()
{
func
(
u
*
HealthCheck
)
Start
()
{
u
.
stop
=
make
(
chan
struct
{})
u
.
stop
=
make
(
chan
struct
{})
if
u
.
Path
!=
""
{
if
u
.
Path
!=
""
{
u
.
wg
.
Add
(
1
)
u
.
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
defer
u
.
wg
.
Done
()
defer
u
.
wg
.
Done
()
u
.
H
ealthCheckWorker
(
u
.
stop
)
u
.
h
ealthCheckWorker
(
u
.
stop
)
}()
}()
}
}
}
}
...
@@ -178,7 +182,7 @@ func (u *HealthCheck) healthCheck() {
...
@@ -178,7 +182,7 @@ func (u *HealthCheck) healthCheck() {
}
}
}
}
func
(
u
*
HealthCheck
)
H
ealthCheckWorker
(
stop
chan
struct
{})
{
func
(
u
*
HealthCheck
)
h
ealthCheckWorker
(
stop
chan
struct
{})
{
ticker
:=
time
.
NewTicker
(
u
.
Interval
)
ticker
:=
time
.
NewTicker
(
u
.
Interval
)
u
.
healthCheck
()
u
.
healthCheck
()
for
{
for
{
...
@@ -192,6 +196,8 @@ func (u *HealthCheck) HealthCheckWorker(stop chan struct{}) {
...
@@ -192,6 +196,8 @@ func (u *HealthCheck) HealthCheckWorker(stop chan struct{}) {
}
}
}
}
// Select selects an upstream host based on the policy
// and the healthcheck result.
func
(
u
*
HealthCheck
)
Select
()
*
UpstreamHost
{
func
(
u
*
HealthCheck
)
Select
()
*
UpstreamHost
{
pool
:=
u
.
Hosts
pool
:=
u
.
Hosts
if
len
(
pool
)
==
1
{
if
len
(
pool
)
==
1
{
...
...
middleware/pkg/healthcheck/policy.go
View file @
c0f62e3f
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
)
)
var
(
var
(
// SupportedPolicies is the collection of policies registered
SupportedPolicies
=
make
(
map
[
string
]
func
()
Policy
)
SupportedPolicies
=
make
(
map
[
string
]
func
()
Policy
)
)
)
...
...
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