Skip to content
This repository has been archived by the owner on Aug 23, 2023. It is now read-only.

fix: Fix wrong model field #42

Merged
merged 1 commit into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/utils/message_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
)

type MessageID struct {
LedgerID int64 `json:"ledgerId"`
EntryID int64 `json:"entryId"`
PartitionedIndex int `json:"partitionedIndex"`
BatchIndex int `json:"-"`
LedgerID int64 `json:"ledgerId"`
EntryID int64 `json:"entryId"`
PartitionIndex int `json:"partitionIndex"`
BatchIndex int `json:"-"`
}

var Latest = MessageID{0x7fffffffffffffff, 0x7fffffffffffffff, -1, -1}
Expand Down Expand Up @@ -58,7 +58,7 @@ func ParseMessageID(str string) (*MessageID, error) {
if err != nil {
return nil, errors.Errorf("invalid partition index. %s", str)
}
m.PartitionedIndex = pi
m.PartitionIndex = pi
}

if len(s) == 4 {
Expand All @@ -75,6 +75,6 @@ func ParseMessageID(str string) (*MessageID, error) {
func (m MessageID) String() string {
return strconv.FormatInt(m.LedgerID, 10) + ":" +
strconv.FormatInt(m.EntryID, 10) + ":" +
strconv.Itoa(m.PartitionedIndex) + ":" +
strconv.Itoa(m.PartitionIndex) + ":" +
strconv.Itoa(m.BatchIndex)
}
6 changes: 3 additions & 3 deletions pkg/utils/message_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import (
func TestParseMessageId(t *testing.T) {
id, err := ParseMessageID("1:1")
assert.Nil(t, err)
assert.Equal(t, MessageID{LedgerID: 1, EntryID: 1, PartitionedIndex: -1, BatchIndex: -1}, *id)
assert.Equal(t, MessageID{LedgerID: 1, EntryID: 1, PartitionIndex: -1, BatchIndex: -1}, *id)

id, err = ParseMessageID("1:2:3")
assert.Nil(t, err)
assert.Equal(t, MessageID{LedgerID: 1, EntryID: 2, PartitionedIndex: 3, BatchIndex: -1}, *id)
assert.Equal(t, MessageID{LedgerID: 1, EntryID: 2, PartitionIndex: 3, BatchIndex: -1}, *id)

id, err = ParseMessageID("1:2:3:4")
assert.Nil(t, err)
assert.Equal(t, MessageID{LedgerID: 1, EntryID: 2, PartitionedIndex: 3, BatchIndex: 4}, *id)
assert.Equal(t, MessageID{LedgerID: 1, EntryID: 2, PartitionIndex: 3, BatchIndex: 4}, *id)
}

func TestParseMessageIdErrors(t *testing.T) {
Expand Down
Loading