mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
storage/etcd: remove newWatcher function
This commit is contained in:
parent
ba10ee7671
commit
6161752ecb
@ -113,7 +113,21 @@ func newStore(c *clientv3.Client, codec runtime.Codec, newFunc func() runtime.Ob
|
|||||||
// Ensure the pathPrefix ends in "/" here to simplify key concatenation later.
|
// Ensure the pathPrefix ends in "/" here to simplify key concatenation later.
|
||||||
pathPrefix += "/"
|
pathPrefix += "/"
|
||||||
}
|
}
|
||||||
result := &store{
|
|
||||||
|
w := &watcher{
|
||||||
|
client: c,
|
||||||
|
codec: codec,
|
||||||
|
groupResource: groupResource,
|
||||||
|
newFunc: newFunc,
|
||||||
|
versioner: versioner,
|
||||||
|
}
|
||||||
|
if newFunc == nil {
|
||||||
|
w.objectType = "<unknown>"
|
||||||
|
} else {
|
||||||
|
w.objectType = reflect.TypeOf(newFunc()).String()
|
||||||
|
}
|
||||||
|
|
||||||
|
s := &store{
|
||||||
client: c,
|
client: c,
|
||||||
codec: codec,
|
codec: codec,
|
||||||
versioner: versioner,
|
versioner: versioner,
|
||||||
@ -122,10 +136,10 @@ func newStore(c *clientv3.Client, codec runtime.Codec, newFunc func() runtime.Ob
|
|||||||
pathPrefix: pathPrefix,
|
pathPrefix: pathPrefix,
|
||||||
groupResource: groupResource,
|
groupResource: groupResource,
|
||||||
groupResourceString: groupResource.String(),
|
groupResourceString: groupResource.String(),
|
||||||
watcher: newWatcher(c, codec, groupResource, newFunc, versioner),
|
watcher: w,
|
||||||
leaseManager: newDefaultLeaseManager(c, leaseManagerConfig),
|
leaseManager: newDefaultLeaseManager(c, leaseManagerConfig),
|
||||||
}
|
}
|
||||||
return result
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// Versioner implements storage.Interface.Versioner.
|
// Versioner implements storage.Interface.Versioner.
|
||||||
|
@ -20,7 +20,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -87,22 +86,6 @@ type watchChan struct {
|
|||||||
errChan chan error
|
errChan chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
func newWatcher(client *clientv3.Client, codec runtime.Codec, groupResource schema.GroupResource, newFunc func() runtime.Object, versioner storage.Versioner) *watcher {
|
|
||||||
res := &watcher{
|
|
||||||
client: client,
|
|
||||||
codec: codec,
|
|
||||||
groupResource: groupResource,
|
|
||||||
newFunc: newFunc,
|
|
||||||
versioner: versioner,
|
|
||||||
}
|
|
||||||
if newFunc == nil {
|
|
||||||
res.objectType = "<unknown>"
|
|
||||||
} else {
|
|
||||||
res.objectType = reflect.TypeOf(newFunc()).String()
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
// Watch watches on a key and returns a watch.Interface that transfers relevant notifications.
|
// Watch watches on a key and returns a watch.Interface that transfers relevant notifications.
|
||||||
// If rev is zero, it will return the existing object(s) and then start watching from
|
// If rev is zero, it will return the existing object(s) and then start watching from
|
||||||
// the maximum revision+1 from returned objects.
|
// the maximum revision+1 from returned objects.
|
||||||
|
Loading…
Reference in New Issue
Block a user