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
cc5ef8c5
Commit
cc5ef8c5
authored
Apr 02, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make undelta store use go's implementatio inheritance mechanism
parent
8ee9ee99
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
26 deletions
+10
-26
undelta_store.go
pkg/client/cache/undelta_store.go
+10
-26
No files found.
pkg/client/cache/undelta_store.go
View file @
cc5ef8c5
...
@@ -24,7 +24,7 @@ package cache
...
@@ -24,7 +24,7 @@ package cache
// in one call to PushFunc, but sometimes PushFunc may be called twice with the same values.
// in one call to PushFunc, but sometimes PushFunc may be called twice with the same values.
// PushFunc should be thread safe.
// PushFunc should be thread safe.
type
UndeltaStore
struct
{
type
UndeltaStore
struct
{
ActualStore
Store
Store
PushFunc
func
([]
interface
{})
PushFunc
func
([]
interface
{})
}
}
...
@@ -43,57 +43,41 @@ var _ Store = &UndeltaStore{}
...
@@ -43,57 +43,41 @@ var _ Store = &UndeltaStore{}
// 5 Store.List() -> [a,b]
// 5 Store.List() -> [a,b]
func
(
u
*
UndeltaStore
)
Add
(
obj
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Add
(
obj
interface
{})
error
{
if
err
:=
u
.
Actual
Store
.
Add
(
obj
);
err
!=
nil
{
if
err
:=
u
.
Store
.
Add
(
obj
);
err
!=
nil
{
return
err
return
err
}
}
u
.
PushFunc
(
u
.
Actual
Store
.
List
())
u
.
PushFunc
(
u
.
Store
.
List
())
return
nil
return
nil
}
}
func
(
u
*
UndeltaStore
)
Update
(
obj
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Update
(
obj
interface
{})
error
{
if
err
:=
u
.
Actual
Store
.
Update
(
obj
);
err
!=
nil
{
if
err
:=
u
.
Store
.
Update
(
obj
);
err
!=
nil
{
return
err
return
err
}
}
u
.
PushFunc
(
u
.
Actual
Store
.
List
())
u
.
PushFunc
(
u
.
Store
.
List
())
return
nil
return
nil
}
}
func
(
u
*
UndeltaStore
)
Delete
(
obj
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Delete
(
obj
interface
{})
error
{
if
err
:=
u
.
Actual
Store
.
Delete
(
obj
);
err
!=
nil
{
if
err
:=
u
.
Store
.
Delete
(
obj
);
err
!=
nil
{
return
err
return
err
}
}
u
.
PushFunc
(
u
.
Actual
Store
.
List
())
u
.
PushFunc
(
u
.
Store
.
List
())
return
nil
return
nil
}
}
func
(
u
*
UndeltaStore
)
List
()
[]
interface
{}
{
return
u
.
ActualStore
.
List
()
}
func
(
u
*
UndeltaStore
)
ListKeys
()
[]
string
{
return
u
.
ActualStore
.
ListKeys
()
}
func
(
u
*
UndeltaStore
)
Get
(
obj
interface
{})
(
item
interface
{},
exists
bool
,
err
error
)
{
return
u
.
ActualStore
.
Get
(
obj
)
}
func
(
u
*
UndeltaStore
)
GetByKey
(
key
string
)
(
item
interface
{},
exists
bool
,
err
error
)
{
return
u
.
ActualStore
.
GetByKey
(
key
)
}
func
(
u
*
UndeltaStore
)
Replace
(
list
[]
interface
{})
error
{
func
(
u
*
UndeltaStore
)
Replace
(
list
[]
interface
{})
error
{
if
err
:=
u
.
Actual
Store
.
Replace
(
list
);
err
!=
nil
{
if
err
:=
u
.
Store
.
Replace
(
list
);
err
!=
nil
{
return
err
return
err
}
}
u
.
PushFunc
(
u
.
Actual
Store
.
List
())
u
.
PushFunc
(
u
.
Store
.
List
())
return
nil
return
nil
}
}
// NewUndeltaStore returns an UndeltaStore implemented with a Store.
// NewUndeltaStore returns an UndeltaStore implemented with a Store.
func
NewUndeltaStore
(
pushFunc
func
([]
interface
{}),
keyFunc
KeyFunc
)
*
UndeltaStore
{
func
NewUndeltaStore
(
pushFunc
func
([]
interface
{}),
keyFunc
KeyFunc
)
*
UndeltaStore
{
return
&
UndeltaStore
{
return
&
UndeltaStore
{
ActualStore
:
NewStore
(
keyFunc
),
Store
:
NewStore
(
keyFunc
),
PushFunc
:
pushFunc
,
PushFunc
:
pushFunc
,
}
}
}
}
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