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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
243ef5d7
Commit
243ef5d7
authored
4 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
fixes logspam issues
parent
0e84f70f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/client.go
+7
-34
7 additions, 34 deletions
bindings/client.go
network/health/tracker.go
+1
-1
1 addition, 1 deletion
network/health/tracker.go
with
8 additions
and
35 deletions
bindings/client.go
+
7
−
34
View file @
243ef5d7
...
@@ -36,7 +36,6 @@ func init() {
...
@@ -36,7 +36,6 @@ func init() {
// to support the gomobile Client interface
// to support the gomobile Client interface
type
Client
struct
{
type
Client
struct
{
api
api
.
Client
api
api
.
Client
waitForNetwork
chan
bool
}
}
// NewClient creates client storage, generates keys, connects, and registers
// NewClient creates client storage, generates keys, connects, and registers
...
@@ -225,41 +224,15 @@ func (c *Client) StopNetworkFollower(timeoutMS int) error {
...
@@ -225,41 +224,15 @@ func (c *Client) StopNetworkFollower(timeoutMS int) error {
// WaitForNewtwork will block until either the network is healthy or the
// WaitForNewtwork will block until either the network is healthy or the
// passed timeout. It will return true if the network is healthy
// passed timeout. It will return true if the network is healthy
func
(
c
*
Client
)
WaitForNetwork
(
timeoutMS
int
)
bool
{
func
(
c
*
Client
)
WaitForNetwork
(
timeoutMS
int
)
bool
{
timeout
:=
time
.
NewTimer
(
time
.
Duration
(
timeoutMS
)
*
time
.
Millisecond
)
start
:=
time
.
Now
()
if
c
.
waitForNetwork
==
nil
{
timeout
:=
time
.
Duration
(
timeoutMS
)
*
time
.
Millisecond
c
.
waitForNetwork
=
make
(
chan
bool
,
1
)
for
time
.
Now
()
.
Sub
(
start
)
<
timeout
{
c
.
api
.
GetHealth
()
.
AddChannel
(
c
.
waitForNetwork
)
}
//flush the channel if it is already full
select
{
case
<-
c
.
waitForNetwork
:
default
:
}
// start a thread to check if healthy in a second in order to handle
// race conditions
go
func
()
{
time
.
Sleep
(
1
*
time
.
Second
)
if
c
.
api
.
GetHealth
()
.
IsHealthy
(){
if
c
.
api
.
GetHealth
()
.
IsHealthy
(){
select
{
case
c
.
waitForNetwork
<-
true
:
default
:
}
}
}()
//wait for network to be healthy or the timer to time out
for
{
select
{
case
result
:=
<-
c
.
waitForNetwork
:
if
result
{
return
true
return
true
}
}
case
<-
timeout
.
C
:
time
.
Sleep
(
250
*
time
.
Millisecond
)
return
false
}
}
}
return
false
}
}
// Gets the state of the network follower. Returns:
// Gets the state of the network follower. Returns:
...
...
This diff is collapsed.
Click to expand it.
network/health/tracker.go
+
1
−
1
View file @
243ef5d7
...
@@ -159,7 +159,7 @@ func (t *Tracker) transmit(health bool) {
...
@@ -159,7 +159,7 @@ func (t *Tracker) transmit(health bool) {
select
{
select
{
case
c
<-
health
:
case
c
<-
health
:
default
:
default
:
jww
.
WARN
.
Printf
(
"Unable to send Health event"
)
jww
.
DEBUG
.
Printf
(
"Unable to send Health event"
)
}
}
}
}
...
...
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