Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f3018162
Commit
f3018162
authored
Sep 23, 2015
by
Eric Tune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Check the condition immediately in util.Wait funcs"
parent
a4d85703
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
7 deletions
+4
-7
wait.go
pkg/util/wait/wait.go
+2
-5
wait_test.go
pkg/util/wait/wait_test.go
+2
-2
No files found.
pkg/util/wait/wait.go
View file @
f3018162
...
@@ -44,6 +44,8 @@ type ConditionFunc func() (done bool, err error)
...
@@ -44,6 +44,8 @@ type ConditionFunc func() (done bool, err error)
// is reached. condition will always be invoked at least once but some intervals
// is reached. condition will always be invoked at least once but some intervals
// may be missed if the condition takes too long or the time window is too short.
// may be missed if the condition takes too long or the time window is too short.
// If you want to Poll something forever, see PollInfinite.
// If you want to Poll something forever, see PollInfinite.
// Poll always waits the interval before the first check of the condition.
// TODO: create a separate PollImmediate function that does not wait.
func
Poll
(
interval
,
timeout
time
.
Duration
,
condition
ConditionFunc
)
error
{
func
Poll
(
interval
,
timeout
time
.
Duration
,
condition
ConditionFunc
)
error
{
return
WaitFor
(
poller
(
interval
,
timeout
),
condition
)
return
WaitFor
(
poller
(
interval
,
timeout
),
condition
)
}
}
...
@@ -88,12 +90,7 @@ func WaitFor(wait WaitFunc, c ConditionFunc) error {
...
@@ -88,12 +90,7 @@ func WaitFor(wait WaitFunc, c ConditionFunc) error {
func
poller
(
interval
,
timeout
time
.
Duration
)
WaitFunc
{
func
poller
(
interval
,
timeout
time
.
Duration
)
WaitFunc
{
return
WaitFunc
(
func
()
<-
chan
struct
{}
{
return
WaitFunc
(
func
()
<-
chan
struct
{}
{
ch
:=
make
(
chan
struct
{})
ch
:=
make
(
chan
struct
{})
go
func
()
{
go
func
()
{
// send to the channel once immediately, rather than waiting for the first
// interval to elapse
ch
<-
struct
{}{}
tick
:=
time
.
NewTicker
(
interval
)
tick
:=
time
.
NewTicker
(
interval
)
defer
tick
.
Stop
()
defer
tick
.
Stop
()
var
after
<-
chan
time
.
Time
var
after
<-
chan
time
.
Time
...
...
pkg/util/wait/wait_test.go
View file @
f3018162
...
@@ -40,8 +40,8 @@ DRAIN:
...
@@ -40,8 +40,8 @@ DRAIN:
t
.
Errorf
(
"unexpected timeout after poll"
)
t
.
Errorf
(
"unexpected timeout after poll"
)
}
}
}
}
if
count
<
2
{
if
count
>
3
{
t
.
Errorf
(
"expected
at least two
values, got %d"
,
count
)
t
.
Errorf
(
"expected
up to three
values, got %d"
,
count
)
}
}
}
}
...
...
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