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
011db554
Commit
011db554
authored
Sep 26, 2015
by
Daniel Martí
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify fake controller lock
parent
d49ca164
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
fake_controller_source.go
pkg/controller/framework/fake_controller_source.go
+7
-7
No files found.
pkg/controller/framework/fake_controller_source.go
View file @
011db554
...
...
@@ -37,7 +37,7 @@ func NewFakeControllerSource() *FakeControllerSource {
// FakeControllerSource implements listing/watching for testing.
type
FakeControllerSource
struct
{
lock
sync
.
RWMutex
sync
.
RWMutex
items
map
[
nnu
]
runtime
.
Object
changes
[]
watch
.
Event
// one change per resourceVersion
broadcaster
*
watch
.
Broadcaster
...
...
@@ -95,8 +95,8 @@ func (f *FakeControllerSource) key(meta *api.ObjectMeta) nnu {
// Change records the given event (setting the object's resource version) and
// sends a watch event with the specified probability.
func
(
f
*
FakeControllerSource
)
Change
(
e
watch
.
Event
,
watchProbability
float64
)
{
f
.
lock
.
Lock
()
defer
f
.
lock
.
Unlock
()
f
.
Lock
()
defer
f
.
Unlock
()
objMeta
,
err
:=
api
.
ObjectMetaFor
(
e
.
Object
)
if
err
!=
nil
{
...
...
@@ -121,8 +121,8 @@ func (f *FakeControllerSource) Change(e watch.Event, watchProbability float64) {
// List returns a list object, with its resource version set.
func
(
f
*
FakeControllerSource
)
List
()
(
runtime
.
Object
,
error
)
{
f
.
lock
.
RLock
()
defer
f
.
lock
.
RUnlock
()
f
.
RLock
()
defer
f
.
RUnlock
()
list
:=
make
([]
runtime
.
Object
,
0
,
len
(
f
.
items
))
for
_
,
obj
:=
range
f
.
items
{
// Must make a copy to allow clients to modify the object.
...
...
@@ -151,8 +151,8 @@ func (f *FakeControllerSource) List() (runtime.Object, error) {
// Watch returns a watch, which will be pre-populated with all changes
// after resourceVersion.
func
(
f
*
FakeControllerSource
)
Watch
(
resourceVersion
string
)
(
watch
.
Interface
,
error
)
{
f
.
lock
.
RLock
()
defer
f
.
lock
.
RUnlock
()
f
.
RLock
()
defer
f
.
RUnlock
()
rc
,
err
:=
strconv
.
Atoi
(
resourceVersion
)
if
err
!=
nil
{
return
nil
,
err
...
...
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