Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pubsublite)!: rename TopicPartitions to TopicPartitionCount #3565

Merged
merged 3 commits into from Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions pubsublite/admin.go
Expand Up @@ -110,9 +110,10 @@ func (ac *AdminClient) Topic(ctx context.Context, topic string) (*TopicConfig, e
return protoToTopicConfig(topicpb)
}

// TopicPartitions returns the number of partitions for a topic. A valid topic
// path has the format: "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID".
func (ac *AdminClient) TopicPartitions(ctx context.Context, topic string) (int, error) {
// TopicPartitionCount returns the number of partitions for a topic. A valid
// topic path has the format:
// "projects/PROJECT_ID/locations/ZONE/topics/TOPIC_ID".
func (ac *AdminClient) TopicPartitionCount(ctx context.Context, topic string) (int, error) {
if _, err := wire.ParseTopicPath(topic); err != nil {
return 0, err
}
Expand Down
10 changes: 5 additions & 5 deletions pubsublite/admin_test.go
Expand Up @@ -108,10 +108,10 @@ func TestAdminTopicCRUD(t *testing.T) {
t.Errorf("Topic() got: %v\nwant: %v", gotConfig, topicConfig)
}

if gotPartitions, err := admin.TopicPartitions(ctx, topicPath); err != nil {
t.Errorf("TopicPartitions() got err: %v", err)
if gotPartitions, err := admin.TopicPartitionCount(ctx, topicPath); err != nil {
t.Errorf("TopicPartitionCount() got err: %v", err)
} else if wantPartitions := 3; gotPartitions != wantPartitions {
t.Errorf("TopicPartitions() got: %v\nwant: %v", gotPartitions, wantPartitions)
t.Errorf("TopicPartitionCount() got: %v\nwant: %v", gotPartitions, wantPartitions)
}

if err := admin.DeleteTopic(ctx, topicPath); err != nil {
Expand Down Expand Up @@ -397,8 +397,8 @@ func TestAdminValidateResourcePaths(t *testing.T) {
if _, err := admin.Topic(ctx, "INVALID"); err == nil {
t.Errorf("Topic() should fail")
}
if _, err := admin.TopicPartitions(ctx, "INVALID"); err == nil {
t.Errorf("TopicPartitions() should fail")
if _, err := admin.TopicPartitionCount(ctx, "INVALID"); err == nil {
t.Errorf("TopicPartitionCount() should fail")
}
if err := admin.DeleteTopic(ctx, "INVALID"); err == nil {
t.Errorf("DeleteTopic() should fail")
Expand Down
4 changes: 2 additions & 2 deletions pubsublite/integration_test.go
Expand Up @@ -163,10 +163,10 @@ func TestIntegration_ResourceAdminOperations(t *testing.T) {
t.Errorf("Topic() got: -, want: +\n%s", diff)
}

if gotTopicPartitions, err := admin.TopicPartitions(ctx, topicPath); err != nil {
if gotTopicPartitions, err := admin.TopicPartitionCount(ctx, topicPath); err != nil {
t.Errorf("Failed to get topic partitions: %v", err)
} else if gotTopicPartitions != newTopicConfig.PartitionCount {
t.Errorf("TopicPartitions() got: %v, want: %v", gotTopicPartitions, newTopicConfig.PartitionCount)
t.Errorf("TopicPartitionCount() got: %v, want: %v", gotTopicPartitions, newTopicConfig.PartitionCount)
}

topicIt := admin.Topics(ctx, locationPath)
Expand Down