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
cb44c7b2
Commit
cb44c7b2
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fix bindings
parent
377549f0
No related branches found
No related tags found
2 merge requests
!510
Release
,
!432
Control node reg
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/follow.go
+27
-6
27 additions, 6 deletions
bindings/follow.go
with
27 additions
and
6 deletions
bindings/follow.go
+
27
−
6
View file @
cb44c7b2
...
@@ -102,13 +102,33 @@ func (c *Cmix) ReadyToSend() bool {
...
@@ -102,13 +102,33 @@ func (c *Cmix) ReadyToSend() bool {
return
numReg
>=
total
*
7
/
10
return
numReg
>=
total
*
7
/
10
}
}
// IsReadyInfo contains information on if the network is ready and how close it
// is to being ready.
//
// Example JSON:
// {
// "IsReady": true,
// "HowClose": 0.534
// }
type
IsReadyInfo
struct
{
IsReady
bool
HowClose
float64
}
// IsReady returns true if at least percentReady of node registrations has
// IsReady returns true if at least percentReady of node registrations has
// completed. If not all have completed, then it returns false and howClose will
// completed. If not all have completed, then it returns false and howClose will
// be a percent (0-1) of node registrations completed.
// be a percent (0-1) of node registrations completed.
func
(
c
*
Cmix
)
IsReady
(
percentReady
float64
)
(
isReady
bool
,
howClose
float64
)
{
//
// 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
// Check if the network is currently healthy
if
!
c
.
api
.
GetCmix
()
.
IsHealthy
()
{
if
!
c
.
api
.
GetCmix
()
.
IsHealthy
()
{
return
false
,
0
return
json
.
Marshal
(
&
IsReadyInfo
{
false
,
0
})
}
}
numReg
,
numNodes
,
err
:=
c
.
api
.
GetNodeRegistrationStatus
()
numReg
,
numNodes
,
err
:=
c
.
api
.
GetNodeRegistrationStatus
()
...
@@ -116,10 +136,10 @@ func (c *Cmix) IsReady(percentReady float64) (isReady bool, howClose float64) {
...
@@ -116,10 +136,10 @@ func (c *Cmix) IsReady(percentReady float64) (isReady bool, howClose float64) {
jww
.
FATAL
.
Panicf
(
"Failed to get node registration status: %+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"Failed to get node registration status: %+v"
,
err
)
}
}
isReady
=
(
float64
(
numReg
)
/
float64
(
numNodes
))
>=
percentReady
isReady
:
=
(
float64
(
numReg
)
/
float64
(
numNodes
))
>=
percentReady
howClose
=
float64
(
numNodes
)
/
(
float64
(
numReg
)
*
percentReady
)
howClose
:
=
float64
(
numNodes
)
/
(
float64
(
numReg
)
*
percentReady
)
return
isReady
,
howClose
return
json
.
Marshal
(
&
IsReadyInfo
{
isReady
,
howClose
})
}
}
// NetworkFollowerStatus gets the state of the network follower. It returns a
// NetworkFollowerStatus gets the state of the network follower. It returns a
...
@@ -177,7 +197,8 @@ func (c *Cmix) PauseNodeRegistrations(timeoutMS int) error {
...
@@ -177,7 +197,8 @@ func (c *Cmix) PauseNodeRegistrations(timeoutMS int) error {
// - toRun - The number of parallel node registrations.
// - toRun - The number of parallel node registrations.
// - timeoutMS - The timeout, in milliseconds, to wait when changing node
// - timeoutMS - The timeout, in milliseconds, to wait when changing node
// registrations.
// registrations.
func
(
c
*
Cmix
)
ChangeNumberOfNodeRegistrations
(
toRun
int
,
timeout
time
.
Duration
)
error
{
func
(
c
*
Cmix
)
ChangeNumberOfNodeRegistrations
(
toRun
,
timeoutMS
int
)
error
{
timeout
:=
time
.
Duration
(
timeoutMS
)
*
time
.
Millisecond
return
c
.
api
.
ChangeNumberOfNodeRegistrations
(
toRun
,
timeout
)
return
c
.
api
.
ChangeNumberOfNodeRegistrations
(
toRun
,
timeout
)
}
}
...
...
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