Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
f8279284
Commit
f8279284
authored
Jan 12, 2021
by
Richard T. Carback III
Browse files
Options
Downloads
Plain Diff
Merge branch 'Ursula/UD' of gitlab.com:elixxir/client into Ursula/UD
parents
3700b09b
6287a8fa
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
interfaces/healthTracker.go
+1
-0
1 addition, 0 deletions
interfaces/healthTracker.go
network/health/tracker.go
+16
-1
16 additions, 1 deletion
network/health/tracker.go
network/health/tracker_test.go
+13
-0
13 additions, 0 deletions
network/health/tracker_test.go
ud/manager.go
+24
-29
24 additions, 29 deletions
ud/manager.go
with
54 additions
and
30 deletions
interfaces/healthTracker.go
+
1
−
0
View file @
f8279284
...
...
@@ -11,4 +11,5 @@ type HealthTracker interface {
AddChannel
(
chan
bool
)
AddFunc
(
f
func
(
bool
))
IsHealthy
()
bool
WasHealthy
()
bool
}
This diff is collapsed.
Click to expand it.
network/health/tracker.go
+
16
−
1
View file @
f8279284
...
...
@@ -28,7 +28,11 @@ type Tracker struct {
running
bool
// Determines the current health status
isHealthy
bool
// Denotes the past health status
// wasHealthy is true if isHealthy has ever been true
wasHealthy
bool
mux
sync
.
RWMutex
}
...
...
@@ -79,8 +83,19 @@ func (t *Tracker) IsHealthy() bool {
return
t
.
isHealthy
}
// Returns true if isHealthy has ever been true
func
(
t
*
Tracker
)
WasHealthy
()
bool
{
t
.
mux
.
RLock
()
defer
t
.
mux
.
RUnlock
()
return
t
.
wasHealthy
}
func
(
t
*
Tracker
)
setHealth
(
h
bool
)
{
t
.
mux
.
Lock
()
// Only set wasHealthy to true if either
// wasHealthy is true or
// wasHealthy false but h value is true
t
.
wasHealthy
=
t
.
wasHealthy
||
h
t
.
isHealthy
=
h
t
.
mux
.
Unlock
()
t
.
transmit
(
h
)
...
...
This diff is collapsed.
Click to expand it.
network/health/tracker_test.go
+
13
−
0
View file @
f8279284
...
...
@@ -72,6 +72,12 @@ func TestNewTracker(t *testing.T) {
return
}
// Check if the tracker was ever healthy
if
!
tracker
.
WasHealthy
()
{
t
.
Errorf
(
"Tracker did not become healthy"
)
return
}
// Verify the heartbeat triggered the listening chan/func
if
counter
!=
expectedCount
{
t
.
Errorf
(
"Expected counter to be %d, got %d"
,
expectedCount
,
counter
)
...
...
@@ -87,6 +93,13 @@ func TestNewTracker(t *testing.T) {
return
}
// Check if the tracker was ever healthy,
// after setting healthy to false
if
!
tracker
.
WasHealthy
()
{
t
.
Errorf
(
"Tracker was healthy previously but not reported healthy"
)
return
}
// Verify the timeout triggered the listening chan/func
if
counter
!=
expectedCount
{
t
.
Errorf
(
"Expected counter to be %d, got %d"
,
expectedCount
,
counter
)
...
...
This diff is collapsed.
Click to expand it.
ud/manager.go
+
24
−
29
View file @
f8279284
...
...
@@ -48,10 +48,9 @@ type Manager struct {
// New manager builds a new user discovery manager. It requires that an
// updated NDF is available and will error if one is not.
func
NewManager
(
client
*
api
.
Client
)
(
*
Manager
,
error
)
{
if
!
client
.
GetHealth
()
.
IsHealthy
(){
if
!
client
.
GetHealth
()
.
WasHealthy
()
{
return
nil
,
errors
.
New
(
"cannot start UD Manager when network "
+
"
i
s n
ot
healthy"
)
"
wa
s n
ever
healthy"
)
}
m
:=
&
Manager
{
...
...
@@ -126,7 +125,3 @@ func (m *Manager) startProcesses() stoppable.Stoppable {
udMulti
.
Add
(
searchStop
)
return
lookupStop
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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