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

[internal branch] Add CreateTopic method to MockCluster #1072

Merged
merged 4 commits into from
Oct 9, 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
5 changes: 2 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

# v2.3.0

This is a maintenance release.

## Fixes
This is a feature release.

* Fixes a bug in the mock schema registry client where the wrong ID was being
returned for pre-registered schema (#971, @srlk).
* Adds `CreateTopic` method to the MockCluster. (#1047, @mimikwang).


# v2.2.0
Expand Down
12 changes: 12 additions & 0 deletions kafka/mockcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ func (mc *MockCluster) SetRoundtripDuration(brokerID int, duration time.Duration
return nil
}

// CreateTopic creates a topic without having to use a producer
func (mc *MockCluster) CreateTopic(topic string, partitions, replicationFactor int) error {
topicStr := C.CString(topic)
defer C.free(unsafe.Pointer(topicStr))

cError := C.rd_kafka_mock_topic_create(mc.mcluster, topicStr, C.int(partitions), C.int(replicationFactor))
if cError != C.RD_KAFKA_RESP_ERR_NO_ERROR {
return newError(cError)
}
return nil
}

// Close and destroy the MockCluster
func (mc *MockCluster) Close() {
C.rd_kafka_mock_cluster_destroy(mc.mcluster)
Expand Down