Skip to content

Commit 9fff7ee

Browse files
committed
update
1 parent 3be3a89 commit 9fff7ee

File tree

8 files changed

+135
-23
lines changed

8 files changed

+135
-23
lines changed

mocks/mockcacheclient/client.go

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mocks/mocktreeentry/entry.go

Lines changed: 84 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/datastore/transaction_rpc.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
treeproto "github.com/sdcio/data-server/pkg/tree/importer/proto"
1313
"github.com/sdcio/data-server/pkg/tree/tree_persist"
1414
treetypes "github.com/sdcio/data-server/pkg/tree/types"
15+
"github.com/sdcio/data-server/pkg/utils"
1516
sdcpb "github.com/sdcio/sdc-protos/sdcpb"
1617
log "github.com/sirupsen/logrus"
1718
)
@@ -45,6 +46,11 @@ func (d *Datastore) SdcpbTransactionIntentToInternalTI(ctx context.Context, req
4546
// add the intent to the TransactionIntent
4647
ti.AddUpdates(Updates)
4748

49+
// add the deletes
50+
for _, d := range req.Deletes {
51+
ti.AddDelete(utils.ToStrings(d, false, false))
52+
}
53+
4854
return ti, nil
4955
}
5056

pkg/datastore/types/transaction_intent.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,19 @@ type TransactionIntent struct {
1111
delete bool
1212
onlyIntended bool
1313
priority int32
14+
// deviation indicates that the intent is a tolerated deviation.
15+
// it will be stored and used for change calculation but will be excluded when claculating actual deviations.
16+
deviation bool
17+
deleteIgnoreNonExisting bool
18+
deletes treetypes.PathSlices
1419
}
1520

1621
func NewTransactionIntent(name string, priority int32) *TransactionIntent {
1722
return &TransactionIntent{
1823
name: name,
1924
updates: make(treetypes.UpdateSlice, 0),
2025
priority: priority,
26+
deletes: make(treetypes.PathSlices, 0),
2127
}
2228
}
2329

@@ -37,6 +43,10 @@ func (ti *TransactionIntent) GetUpdates() treetypes.UpdateSlice {
3743
return ti.updates
3844
}
3945

46+
func (ti *TransactionIntent) GetDeletes() treetypes.PathSlices {
47+
return ti.deletes
48+
}
49+
4050
func (ti *TransactionIntent) GetOnlyIntended() bool {
4151
return ti.onlyIntended
4252
}
@@ -56,3 +66,7 @@ func (ti *TransactionIntent) GetPathSet() *treetypes.PathSet {
5666
func (ti *TransactionIntent) AddUpdate(u *treetypes.Update) {
5767
ti.updates = append(ti.updates, u)
5868
}
69+
70+
func (ti *TransactionIntent) AddDelete(p treetypes.PathSlice) {
71+
ti.deletes = append(ti.deletes, p)
72+
}

pkg/tree/entry.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,6 @@ type Entry interface {
158158
}
159159

160160
type EntryVisitor interface {
161-
Visit(ctx context.Context, s *sharedEntryAttributes) error
161+
Visit(ctx context.Context, e Entry) error
162162
Up()
163163
}

pkg/tree/leaf_entry.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type LeafEntry struct {
1919
Delete bool
2020
DeleteOnlyIntended bool
2121
IsUpdated bool
22+
IsExplicitDelete bool
2223

2324
mu sync.RWMutex
2425
}
@@ -31,6 +32,7 @@ func (l *LeafEntry) DeepCopy(parentEntry Entry) *LeafEntry {
3132
Delete: l.Delete,
3233
DeleteOnlyIntended: l.DeleteOnlyIntended,
3334
IsUpdated: l.IsUpdated,
35+
IsExplicitDelete: l.IsExplicitDelete,
3436
mu: sync.RWMutex{},
3537
}
3638
}
@@ -73,6 +75,12 @@ func (l *LeafEntry) GetDeleteFlag() bool {
7375
return l.Delete
7476
}
7577

78+
func (l *LeafEntry) GetExplicitDeleteFlag() bool {
79+
l.mu.RLock()
80+
defer l.mu.RUnlock()
81+
return l.IsExplicitDelete
82+
}
83+
7684
func (l *LeafEntry) GetDeleteOnlyIntendedFlag() bool {
7785
l.mu.RLock()
7886
defer l.mu.RUnlock()
@@ -110,13 +118,9 @@ func (l *LeafEntry) MarkDelete(onlyIntended bool) {
110118
l.IsNew = false
111119
}
112120

113-
func (l *LeafEntry) GetRootBasedEntryChain() []Entry {
114-
return l.parentEntry.GetRootBasedEntryChain()
115-
}
116-
117121
// String returns a string representation of the LeafEntry
118122
func (l *LeafEntry) String() string {
119-
return fmt.Sprintf("Owner: %s, Priority: %d, Value: %s, New: %t, Delete: %t, Update: %t, DeleteIntendedOnly: %t", l.Owner(), l.Priority(), utils.TypedValueToString(l.Value()), l.GetNewFlag(), l.GetDeleteFlag(), l.GetUpdateFlag(), l.GetDeleteOnlyIntendedFlag())
123+
return fmt.Sprintf("Owner: %s, Priority: %d, Value: %s, New: %t, Delete: %t, Update: %t, DeleteIntendedOnly: %t, ExplicitDelete: %t", l.Owner(), l.Priority(), utils.TypedValueToString(l.Value()), l.GetNewFlag(), l.GetDeleteFlag(), l.GetUpdateFlag(), l.GetDeleteOnlyIntendedFlag(), l.GetExplicitDeleteFlag())
120124
}
121125

122126
// NewLeafEntry constructor for a new LeafEntry

pkg/tree/types/update_insert_flags.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ type LeafEntry interface {
66
}
77

88
type UpdateInsertFlags struct {
9-
new bool
10-
delete bool
11-
onlyIntended bool
9+
new bool
10+
delete bool
11+
onlyIntended bool
12+
explicitDelete bool
1213
}
1314

1415
// NewUpdateInsertFlags returns a new *UpdateInsertFlags instance
@@ -17,6 +18,17 @@ func NewUpdateInsertFlags() *UpdateInsertFlags {
1718
return &UpdateInsertFlags{}
1819
}
1920

21+
func (f *UpdateInsertFlags) GetExplicitDeleteFlag() bool {
22+
return f.explicitDelete
23+
}
24+
25+
func (f *UpdateInsertFlags) SetExplicitDeleteFlag() *UpdateInsertFlags {
26+
f.explicitDelete = true
27+
f.delete = true
28+
f.new = false
29+
return f
30+
}
31+
2032
func (f *UpdateInsertFlags) SetDeleteFlag() *UpdateInsertFlags {
2133
f.delete = true
2234
f.new = false

pkg/tree/xml_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,11 @@ func TestToXMLTable(t *testing.T) {
412412
}
413413
return upds, nil
414414
},
415-
expected: ``,
415+
expected: ``,
416416
honorNamespace: true,
417417
operationWithNamespace: true,
418418
useOperationRemove: true,
419-
newConfig: nil,
419+
newConfig: nil,
420420
},
421421
}
422422

0 commit comments

Comments
 (0)