From c105feaea7c601b6013e1057e827be7f89a701fa Mon Sep 17 00:00:00 2001 From: steiler Date: Thu, 21 May 2026 11:24:31 +0200 Subject: [PATCH] Remove unused / dead cache update type dependency and related helpers --- pkg/cache/cache.go | 99 +++++++++---------- .../tree_operation_validation_test.go | 3 +- pkg/utils/value.go | 43 ++++---- 3 files changed, 69 insertions(+), 76 deletions(-) diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 94287a51..f0c39fdd 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -16,11 +16,8 @@ package cache import ( "context" - "fmt" - sdcpb "github.com/sdcio/sdc-protos/sdcpb" "github.com/sdcio/sdc-protos/tree_persist" - "google.golang.org/protobuf/proto" ) type Client interface { @@ -37,59 +34,59 @@ type Client interface { InstanceIntentGetAll(ctx context.Context, cacheName string, excludeIntentNames []string, intentChan chan<- *tree_persist.Intent, errChan chan<- error) } -type Update struct { - path []string - value []byte - priority int32 - owner string - ts int64 -} +// type Update struct { +// path []string +// value []byte +// priority int32 +// owner string +// ts int64 +// } -func NewUpdate(path []string, value []byte, priority int32, owner string, ts int64) *Update { - return &Update{ - path: path, - value: value, - priority: priority, - owner: owner, - ts: ts, - } -} +// func NewUpdate(path []string, value []byte, priority int32, owner string, ts int64) *Update { +// return &Update{ +// path: path, +// value: value, +// priority: priority, +// owner: owner, +// ts: ts, +// } +// } -func (u *Update) GetPath() []string { - return u.path -} +// func (u *Update) GetPath() []string { +// return u.path +// } -func (u *Update) Value() (*sdcpb.TypedValue, error) { - tv := new(sdcpb.TypedValue) - err := proto.Unmarshal(u.value, tv) - if err != nil { - return nil, err - } - return tv, nil -} +// func (u *Update) Value() (*sdcpb.TypedValue, error) { +// tv := new(sdcpb.TypedValue) +// err := proto.Unmarshal(u.value, tv) +// if err != nil { +// return nil, err +// } +// return tv, nil +// } -func (u *Update) Bytes() []byte { - return u.value -} +// func (u *Update) Bytes() []byte { +// return u.value +// } -func (u *Update) Priority() int32 { - return u.priority -} +// func (u *Update) Priority() int32 { +// return u.priority +// } -func (u *Update) Owner() string { - return u.owner -} +// func (u *Update) Owner() string { +// return u.owner +// } -func (u *Update) TS() int64 { - return u.ts -} +// func (u *Update) TS() int64 { +// return u.ts +// } -func (u *Update) String() string { - val := "error decoding value" - v, err := u.Value() - if err == nil { - // if no error occured we use the value - val = v.String() - } - return fmt.Sprintf("path: %s, owner: %s, priority: %d, value: %s", u.path, u.owner, u.priority, val) -} +// func (u *Update) String() string { +// val := "error decoding value" +// v, err := u.Value() +// if err == nil { +// // if no error occured we use the value +// val = v.String() +// } +// return fmt.Sprintf("path: %s, owner: %s, priority: %d, value: %s", u.path, u.owner, u.priority, val) +// } diff --git a/pkg/datastore/tree_operation_validation_test.go b/pkg/datastore/tree_operation_validation_test.go index 652658f5..cf812c3e 100644 --- a/pkg/datastore/tree_operation_validation_test.go +++ b/pkg/datastore/tree_operation_validation_test.go @@ -23,7 +23,6 @@ import ( "testing" "github.com/openconfig/ygot/ygot" - "github.com/sdcio/data-server/pkg/cache" schemaClient "github.com/sdcio/data-server/pkg/datastore/clients/schema" "github.com/sdcio/data-server/pkg/pool" "github.com/sdcio/data-server/pkg/tree" @@ -57,7 +56,7 @@ func TestDatastore_validateTree(t *testing.T) { intentName string intentPrio int32 intentDelete bool - intendedStoreUpdates []*cache.Update + intendedStoreUpdates []*types.Update NotOnlyNewOrUpdated bool // it negated when used in the call, usually we want it to be true expectedWarnings []string nonRevertive bool diff --git a/pkg/utils/value.go b/pkg/utils/value.go index bbe42070..f79b82cc 100644 --- a/pkg/utils/value.go +++ b/pkg/utils/value.go @@ -21,10 +21,7 @@ import ( "strings" "github.com/openconfig/gnmi/proto/gnmi" - "github.com/sdcio/data-server/pkg/cache" - "github.com/sdcio/schema-server/pkg/utils" sdcpb "github.com/sdcio/sdc-protos/sdcpb" - "google.golang.org/protobuf/proto" ) func GetJsonValue(tv *sdcpb.TypedValue, ietf bool) (any, error) { @@ -234,23 +231,23 @@ func BoolPtr(b bool) *bool { return &b } -func SdcpbUpdateToCacheUpdate(upd *sdcpb.Update, owner string, prio int32) (*cache.Update, error) { - b, err := proto.Marshal(upd.Value) - if err != nil { - return nil, err - } - return cache.NewUpdate(utils.ToStrings(upd.GetPath(), false, false), b, prio, owner, 0), nil -} - -func SdcpbUpdatesToCacheUpdates(upds []*sdcpb.Update, owner string, prio int32) ([]*cache.Update, error) { - result := []*cache.Update{} - for _, upd := range upds { - cUpd, err := SdcpbUpdateToCacheUpdate(upd, owner, prio) - if err != nil { - return nil, err - } - result = append(result, cUpd) - } - - return result, nil -} +// func SdcpbUpdateToCacheUpdate(upd *sdcpb.Update, owner string, prio int32) (*cache.Update, error) { +// b, err := proto.Marshal(upd.Value) +// if err != nil { +// return nil, err +// } +// return cache.NewUpdate(utils.ToStrings(upd.GetPath(), false, false), b, prio, owner, 0), nil +// } + +// func SdcpbUpdatesToCacheUpdates(upds []*sdcpb.Update, owner string, prio int32) ([]*cache.Update, error) { +// result := []*cache.Update{} +// for _, upd := range upds { +// cUpd, err := SdcpbUpdateToCacheUpdate(upd, owner, prio) +// if err != nil { +// return nil, err +// } +// result = append(result, cUpd) +// } + +// return result, nil +// }