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
a607a69f
Commit
a607a69f
authored
Aug 15, 2016
by
Hongchao Deng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/storage: cleanup Codec() from interface
parent
79ed7064
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
8 additions
and
20 deletions
+8
-20
storage_factory.go
pkg/registry/generic/registry/storage_factory.go
+1
-0
store_test.go
pkg/registry/generic/registry/store_test.go
+3
-1
cacher.go
pkg/storage/cacher.go
+3
-6
cacher_test.go
pkg/storage/cacher_test.go
+1
-0
etcd_helper.go
pkg/storage/etcd/etcd_helper.go
+0
-5
store.go
pkg/storage/etcd3/store.go
+0
-5
interfaces.go
pkg/storage/interfaces.go
+0
-3
No files found.
pkg/registry/generic/registry/storage_factory.go
View file @
a607a69f
...
@@ -45,6 +45,7 @@ func StorageWithCacher(
...
@@ -45,6 +45,7 @@ func StorageWithCacher(
ResourcePrefix
:
resourcePrefix
,
ResourcePrefix
:
resourcePrefix
,
NewListFunc
:
newListFunc
,
NewListFunc
:
newListFunc
,
TriggerPublisherFunc
:
triggerFunc
,
TriggerPublisherFunc
:
triggerFunc
,
Codec
:
storageConfig
.
Codec
,
}
}
if
scopeStrategy
.
NamespaceScoped
()
{
if
scopeStrategy
.
NamespaceScoped
()
{
cacherConfig
.
KeyFunc
=
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
cacherConfig
.
KeyFunc
=
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
...
...
pkg/registry/generic/registry/store_test.go
View file @
a607a69f
...
@@ -1015,7 +1015,8 @@ func newTestGenericStoreRegistry(t *testing.T, hasCacheEnabled bool) (*etcdtesti
...
@@ -1015,7 +1015,8 @@ func newTestGenericStoreRegistry(t *testing.T, hasCacheEnabled bool) (*etcdtesti
podPrefix
:=
"/pods"
podPrefix
:=
"/pods"
server
:=
etcdtesting
.
NewEtcdTestClientServer
(
t
)
server
:=
etcdtesting
.
NewEtcdTestClientServer
(
t
)
strategy
:=
&
testRESTStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
,
true
,
false
,
true
}
strategy
:=
&
testRESTStrategy
{
api
.
Scheme
,
api
.
SimpleNameGenerator
,
true
,
false
,
true
}
s
:=
etcdstorage
.
NewEtcdStorage
(
server
.
Client
,
testapi
.
Default
.
StorageCodec
(),
etcdtest
.
PathPrefix
(),
false
,
etcdtest
.
DeserializationCacheSize
)
codec
:=
testapi
.
Default
.
StorageCodec
()
s
:=
etcdstorage
.
NewEtcdStorage
(
server
.
Client
,
codec
,
etcdtest
.
PathPrefix
(),
false
,
etcdtest
.
DeserializationCacheSize
)
if
hasCacheEnabled
{
if
hasCacheEnabled
{
config
:=
storage
.
CacherConfig
{
config
:=
storage
.
CacherConfig
{
CacheCapacity
:
10
,
CacheCapacity
:
10
,
...
@@ -1025,6 +1026,7 @@ func newTestGenericStoreRegistry(t *testing.T, hasCacheEnabled bool) (*etcdtesti
...
@@ -1025,6 +1026,7 @@ func newTestGenericStoreRegistry(t *testing.T, hasCacheEnabled bool) (*etcdtesti
ResourcePrefix
:
podPrefix
,
ResourcePrefix
:
podPrefix
,
KeyFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
return
storage
.
NoNamespaceKeyFunc
(
podPrefix
,
obj
)
},
KeyFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
return
storage
.
NoNamespaceKeyFunc
(
podPrefix
,
obj
)
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodList
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodList
{}
},
Codec
:
codec
,
}
}
s
=
storage
.
NewCacherFromConfig
(
config
)
s
=
storage
.
NewCacherFromConfig
(
config
)
}
}
...
...
pkg/storage/cacher.go
View file @
a607a69f
...
@@ -65,6 +65,8 @@ type CacherConfig struct {
...
@@ -65,6 +65,8 @@ type CacherConfig struct {
// NewList is a function that creates new empty object storing a list of
// NewList is a function that creates new empty object storing a list of
// objects of type Type.
// objects of type Type.
NewListFunc
func
()
runtime
.
Object
NewListFunc
func
()
runtime
.
Object
Codec
runtime
.
Codec
}
}
type
watchersMap
map
[
int
]
*
cacheWatcher
type
watchersMap
map
[
int
]
*
cacheWatcher
...
@@ -176,7 +178,7 @@ func NewCacherFromConfig(config CacherConfig) *Cacher {
...
@@ -176,7 +178,7 @@ func NewCacherFromConfig(config CacherConfig) *Cacher {
// Give this error when it is constructed rather than when you get the
// Give this error when it is constructed rather than when you get the
// first watch item, because it's much easier to track down that way.
// first watch item, because it's much easier to track down that way.
if
obj
,
ok
:=
config
.
Type
.
(
runtime
.
Object
);
ok
{
if
obj
,
ok
:=
config
.
Type
.
(
runtime
.
Object
);
ok
{
if
err
:=
runtime
.
CheckCodec
(
config
.
Storage
.
Codec
()
,
obj
);
err
!=
nil
{
if
err
:=
runtime
.
CheckCodec
(
config
.
Codec
,
obj
);
err
!=
nil
{
panic
(
"storage codec doesn't seem to match given type: "
+
err
.
Error
())
panic
(
"storage codec doesn't seem to match given type: "
+
err
.
Error
())
}
}
}
}
...
@@ -375,11 +377,6 @@ func (c *Cacher) GuaranteedUpdate(ctx context.Context, key string, ptrToType run
...
@@ -375,11 +377,6 @@ func (c *Cacher) GuaranteedUpdate(ctx context.Context, key string, ptrToType run
return
c
.
storage
.
GuaranteedUpdate
(
ctx
,
key
,
ptrToType
,
ignoreNotFound
,
preconditions
,
tryUpdate
)
return
c
.
storage
.
GuaranteedUpdate
(
ctx
,
key
,
ptrToType
,
ignoreNotFound
,
preconditions
,
tryUpdate
)
}
}
// Implements storage.Interface.
func
(
c
*
Cacher
)
Codec
()
runtime
.
Codec
{
return
c
.
storage
.
Codec
()
}
func
(
c
*
Cacher
)
triggerValues
(
event
*
watchCacheEvent
)
([]
string
,
bool
)
{
func
(
c
*
Cacher
)
triggerValues
(
event
*
watchCacheEvent
)
([]
string
,
bool
)
{
// TODO: Currently we assume that in a given Cacher object, its <c.triggerFunc>
// TODO: Currently we assume that in a given Cacher object, its <c.triggerFunc>
// is aware of exactly the same trigger (at most one). Thus calling:
// is aware of exactly the same trigger (at most one). Thus calling:
...
...
pkg/storage/cacher_test.go
View file @
a607a69f
...
@@ -59,6 +59,7 @@ func newTestCacher(s storage.Interface) *storage.Cacher {
...
@@ -59,6 +59,7 @@ func newTestCacher(s storage.Interface) *storage.Cacher {
ResourcePrefix
:
prefix
,
ResourcePrefix
:
prefix
,
KeyFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
return
storage
.
NamespaceKeyFunc
(
prefix
,
obj
)
},
KeyFunc
:
func
(
obj
runtime
.
Object
)
(
string
,
error
)
{
return
storage
.
NamespaceKeyFunc
(
prefix
,
obj
)
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodList
{}
},
NewListFunc
:
func
()
runtime
.
Object
{
return
&
api
.
PodList
{}
},
Codec
:
testapi
.
Default
.
Codec
(),
}
}
return
storage
.
NewCacherFromConfig
(
config
)
return
storage
.
NewCacherFromConfig
(
config
)
}
}
...
...
pkg/storage/etcd/etcd_helper.go
View file @
a607a69f
...
@@ -85,11 +85,6 @@ func init() {
...
@@ -85,11 +85,6 @@ func init() {
metrics
.
Register
()
metrics
.
Register
()
}
}
// Codec provides access to the underlying codec being used by the implementation.
func
(
h
*
etcdHelper
)
Codec
()
runtime
.
Codec
{
return
h
.
codec
}
// Implements storage.Interface.
// Implements storage.Interface.
func
(
h
*
etcdHelper
)
Versioner
()
storage
.
Versioner
{
func
(
h
*
etcdHelper
)
Versioner
()
storage
.
Versioner
{
return
h
.
versioner
return
h
.
versioner
...
...
pkg/storage/etcd3/store.go
View file @
a607a69f
...
@@ -73,11 +73,6 @@ func newStore(c *clientv3.Client, codec runtime.Codec, prefix string) *store {
...
@@ -73,11 +73,6 @@ func newStore(c *clientv3.Client, codec runtime.Codec, prefix string) *store {
}
}
}
}
// Codec implements storage.Interface.Codec.
func
(
s
*
store
)
Codec
()
runtime
.
Codec
{
return
s
.
codec
}
// Versioner implements storage.Interface.Versioner.
// Versioner implements storage.Interface.Versioner.
func
(
s
*
store
)
Versioner
()
storage
.
Versioner
{
func
(
s
*
store
)
Versioner
()
storage
.
Versioner
{
return
s
.
versioner
return
s
.
versioner
...
...
pkg/storage/interfaces.go
View file @
a607a69f
...
@@ -182,9 +182,6 @@ type Interface interface {
...
@@ -182,9 +182,6 @@ type Interface interface {
// }
// }
// })
// })
GuaranteedUpdate
(
ctx
context
.
Context
,
key
string
,
ptrToType
runtime
.
Object
,
ignoreNotFound
bool
,
precondtions
*
Preconditions
,
tryUpdate
UpdateFunc
)
error
GuaranteedUpdate
(
ctx
context
.
Context
,
key
string
,
ptrToType
runtime
.
Object
,
ignoreNotFound
bool
,
precondtions
*
Preconditions
,
tryUpdate
UpdateFunc
)
error
// Codec provides access to the underlying codec being used by the implementation.
Codec
()
runtime
.
Codec
}
}
// Config interface allows storage tiers to generate the proper storage.interface
// Config interface allows storage tiers to generate the proper storage.interface
...
...
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