mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Allow to watch from the dual writer (#91375)
* Allow to watch from the dual writer * Remove comments * Lint
This commit is contained in:
parent
a32854549c
commit
fb9903ed7c
@ -8,13 +8,15 @@ import (
|
|||||||
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DualWriterMode3 struct {
|
type DualWriterMode3 struct {
|
||||||
Legacy LegacyStorage
|
Legacy LegacyStorage
|
||||||
Storage Storage
|
Storage Storage
|
||||||
|
watchImp rest.Watcher // watch is only available in mode 3 and 4
|
||||||
*dualWriterMetrics
|
*dualWriterMetrics
|
||||||
kind string
|
kind string
|
||||||
Log klog.Logger
|
Log klog.Logger
|
||||||
@ -170,12 +172,11 @@ func (d *DualWriterMode3) DeleteCollection(ctx context.Context, deleteValidation
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: uncomment when storage watch is implemented
|
func (d *DualWriterMode3) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
||||||
// func (d *DualWriterMode3) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
var method = "watch"
|
||||||
// var method = "watch"
|
d.Log.WithValues("method", method, "mode", mode3Str).Info("starting to watch")
|
||||||
// d.Log.WithValues("kind", d.kind, "method", method, "mode", mode3Str).Info("starting to watch")
|
return d.watchImp.Watch(ctx, options)
|
||||||
// return d.Storage.Watch(ctx, options)
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
func (d *DualWriterMode3) Destroy() {
|
func (d *DualWriterMode3) Destroy() {
|
||||||
d.Storage.Destroy()
|
d.Storage.Destroy()
|
||||||
|
@ -7,13 +7,15 @@ import (
|
|||||||
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
metainternalversion "k8s.io/apimachinery/pkg/apis/meta/internalversion"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/apiserver/pkg/registry/rest"
|
"k8s.io/apiserver/pkg/registry/rest"
|
||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DualWriterMode4 struct {
|
type DualWriterMode4 struct {
|
||||||
Legacy LegacyStorage
|
Legacy LegacyStorage
|
||||||
Storage Storage
|
Storage Storage
|
||||||
|
watchImp rest.Watcher // watch is only available in mode 3 and 4
|
||||||
*dualWriterMetrics
|
*dualWriterMetrics
|
||||||
kind string
|
kind string
|
||||||
Log klog.Logger
|
Log klog.Logger
|
||||||
@ -122,12 +124,11 @@ func (d *DualWriterMode4) List(ctx context.Context, options *metainternalversion
|
|||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: uncomment when storage watch is implemented
|
func (d *DualWriterMode4) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
||||||
// func (d *DualWriterMode4) Watch(ctx context.Context, options *metainternalversion.ListOptions) (watch.Interface, error) {
|
var method = "watch"
|
||||||
// var method = "watch"
|
d.Log.WithValues("method", method, "mode", mode4Str).Info("starting to watch")
|
||||||
// d.Log.WithValues("kind", d.kind, "method", method, "mode", mode4Str).Info("starting to watch")
|
return d.watchImp.Watch(ctx, options)
|
||||||
// return d.Storage.Watch(ctx, options)
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
func (d *DualWriterMode4) Destroy() {
|
func (d *DualWriterMode4) Destroy() {
|
||||||
d.Storage.Destroy()
|
d.Storage.Destroy()
|
||||||
|
Loading…
Reference in New Issue
Block a user