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
1ce924df
Commit
1ce924df
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Move IsReady to xxDK
parent
7a69cc6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!510
Release
,
!432
Control node reg
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/follow.go
+15
-27
15 additions, 27 deletions
bindings/follow.go
xxdk/cmix.go
+22
-0
22 additions, 0 deletions
xxdk/cmix.go
with
37 additions
and
27 deletions
bindings/follow.go
+
15
−
27
View file @
1ce924df
...
...
@@ -115,33 +115,6 @@ type IsReadyInfo struct {
HowClose
float64
}
// IsReady returns true if at least percentReady of node registrations has
// completed. If not all have completed, then it returns false and howClose will
// be a percent (0-1) of node registrations completed.
//
// Parameters:
// - percentReady - The percentage of nodes required to be registered with to
// be ready. This is a number between 0 and 1.
//
// Returns:
// - JSON of [IsReadyInfo].
func
(
c
*
Cmix
)
IsReady
(
percentReady
float64
)
([]
byte
,
error
)
{
// Check if the network is currently healthy
if
!
c
.
api
.
GetCmix
()
.
IsHealthy
()
{
return
json
.
Marshal
(
&
IsReadyInfo
{
false
,
0
})
}
numReg
,
numNodes
,
err
:=
c
.
api
.
GetNodeRegistrationStatus
()
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to get node registration status: %+v"
,
err
)
}
isReady
:=
(
float64
(
numReg
)
/
float64
(
numNodes
))
>=
percentReady
howClose
:=
float64
(
numReg
)
/
(
float64
(
numNodes
)
*
percentReady
)
return
json
.
Marshal
(
&
IsReadyInfo
{
isReady
,
howClose
})
}
// NetworkFollowerStatus gets the state of the network follower. It returns a
// status with the following values:
// Stopped - 0
...
...
@@ -180,6 +153,21 @@ func (c *Cmix) GetNodeRegistrationStatus() ([]byte, error) {
return
json
.
Marshal
(
nodeRegReport
)
}
// IsReady returns true if at least percentReady of node registrations has
// completed. If not all have completed, then it returns false and howClose will
// be a percent (0-1) of node registrations completed.
//
// Parameters:
// - percentReady - The percentage of nodes required to be registered with to
// be ready. This is a number between 0 and 1.
//
// Returns:
// - JSON of [IsReadyInfo].
func
(
c
*
Cmix
)
IsReady
(
percentReady
float64
)
([]
byte
,
error
)
{
isReady
,
howClose
:=
c
.
api
.
IsReady
(
percentReady
)
return
json
.
Marshal
(
&
IsReadyInfo
{
isReady
,
howClose
})
}
// PauseNodeRegistrations stops all node registrations and returns a function to
// resume them.
//
...
...
This diff is collapsed.
Click to expand it.
xxdk/cmix.go
+
22
−
0
View file @
1ce924df
...
...
@@ -484,6 +484,28 @@ func (c *Cmix) GetNodeRegistrationStatus() (int, int, error) {
return
numRegistered
,
len
(
nodes
)
-
numStale
,
nil
}
// IsReady returns true if at least percentReady of node registrations has
// completed. If not all have completed, then it returns false and howClose will
// be a percent (0-1) of node registrations completed.
func
(
c
*
Cmix
)
IsReady
(
percentReady
float64
)
(
isReady
bool
,
howClose
float64
)
{
// Check if the network is currently healthy
if
!
c
.
network
.
IsHealthy
()
{
return
false
,
0
}
numReg
,
numNodes
,
err
:=
c
.
GetNodeRegistrationStatus
()
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"Failed to get node registration status: %+v"
,
err
)
}
isReady
=
(
float64
(
numReg
)
/
float64
(
numNodes
))
>=
percentReady
howClose
=
float64
(
numReg
)
/
(
float64
(
numNodes
)
*
percentReady
)
return
isReady
,
howClose
}
// PauseNodeRegistrations stops all node registrations and returns a function to
// resume them.
func
(
c
*
Cmix
)
PauseNodeRegistrations
(
timeout
time
.
Duration
)
error
{
...
...
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