-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: time index lookup; shifted topic partition hash into a proto schema
- Loading branch information
1 parent
9582d0e
commit ab7d0cc
Showing
11 changed files
with
468 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
package api | ||
|
||
import "fmt" | ||
import ( | ||
"fmt" | ||
apiv1 "github.com/yarefs/carnax/gen/api/v1" | ||
) | ||
|
||
type TopicPartitionHash string | ||
type TopicPartitionHash apiv1.TopicPartition | ||
|
||
func tpHash(topic string, partitionIndex uint32) TopicPartitionHash { | ||
rawHash := fmt.Sprintf("%s-%d", topic, partitionIndex) | ||
return TopicPartitionHash(rawHash) | ||
func (t *TopicPartitionHash) String() string { | ||
return fmt.Sprintf("%s-%d", t.Topic, t.PartitionIndex) | ||
} | ||
|
||
func newTopicHash(topic string, partitionIndex uint32) *TopicPartitionHash { | ||
tp := &apiv1.TopicPartition{ | ||
Topic: topic, | ||
PartitionIndex: partitionIndex, | ||
} | ||
return (*TopicPartitionHash)(tp) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package api | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestTopicPartitionHash_String(t *testing.T) { | ||
res := newTopicHash("foo", 123) | ||
assert.Equal(t, "foo-123", res.String()) | ||
} |
Oops, something went wrong.