Skip to content

Commit 8a79f83

Browse files
committed
fix: correct state consistency types
Signed-off-by: mikeee <[email protected]>
1 parent 61158e8 commit 8a79f83

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

Diff for: client/state.go

+19-6
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,19 @@ const (
4646
StateOperationTypeUpsert OperationType = 1
4747
// StateOperationTypeDelete represents delete operation type value.
4848
StateOperationTypeDelete OperationType = 2
49+
50+
// EventualType represents the eventual type value.
51+
EventualType = "eventual"
52+
// StrongType represents the strong type value.
53+
StrongType = "strong"
54+
// FirstWriteType represents the first write type value.
55+
FirstWriteType = "first-write"
56+
// LastWriteType represents the last write type value.
57+
LastWriteType = "last-write"
58+
// UpsertType represents the upsert type value.
59+
UpsertType = "upsert"
60+
// DeleteType represents the delete type value.
61+
DeleteType = "delete"
4962
// UndefinedType represents undefined type value.
5063
UndefinedType = "undefined"
5164
)
@@ -73,8 +86,8 @@ func (s StateConcurrency) GetPBConcurrency() v1.StateOptions_StateConcurrency {
7386
func (o OperationType) String() string {
7487
names := [...]string{
7588
UndefinedType,
76-
"upsert",
77-
"delete",
89+
UpsertType,
90+
DeleteType,
7891
}
7992
if o < StateOperationTypeUpsert || o > StateOperationTypeDelete {
8093
return UndefinedType
@@ -87,8 +100,8 @@ func (o OperationType) String() string {
87100
func (s StateConsistency) String() string {
88101
names := [...]string{
89102
UndefinedType,
90-
"eventual",
91-
"strong",
103+
EventualType,
104+
StrongType,
92105
}
93106
if s < StateConsistencyEventual || s > StateConsistencyStrong {
94107
return UndefinedType
@@ -101,8 +114,8 @@ func (s StateConsistency) String() string {
101114
func (s StateConcurrency) String() string {
102115
names := [...]string{
103116
UndefinedType,
104-
"first-write",
105-
"last-write",
117+
FirstWriteType,
118+
LastWriteType,
106119
}
107120
if s < StateConcurrencyFirstWrite || s > StateConcurrencyLastWrite {
108121
return UndefinedType

Diff for: client/state_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ func TestTypes(t *testing.T) {
3535
var a OperationType = -1
3636
assert.Equal(t, UndefinedType, a.String())
3737
a = 2
38-
assert.Equal(t, "delete", a.String())
38+
assert.Equal(t, DeleteType, a.String())
3939
})
4040
t.Run("test state concurrency type", func(t *testing.T) {
4141
var b StateConcurrency = -1
4242
assert.Equal(t, UndefinedType, b.String())
4343
b = 2
44-
assert.Equal(t, "last-write", b.String())
44+
assert.Equal(t, LastWriteType, b.String())
4545
})
4646
t.Run("test state consistency type", func(t *testing.T) {
4747
var c StateConsistency = -1
4848
assert.Equal(t, UndefinedType, c.String())
4949
c = 2
50-
assert.Equal(t, "strong", c.String())
50+
assert.Equal(t, StrongType, c.String())
5151
})
5252
}
5353

0 commit comments

Comments
 (0)