Skip to content

Commit 35cc73e

Browse files
committed
Refactor Pulsar Admin Tools to Remove Redundant Alias for Utils
- Removed the alias for the `utils` package in multiple files, simplifying imports and improving code clarity. - Updated references to use the direct `utils` package instead of the alias, ensuring consistency across the codebase. - Enhanced readability by streamlining the import statements and maintaining a clear structure.
1 parent c5ddc05 commit 35cc73e

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

pkg/mcp/pftools/invocation.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"time"
2828

2929
"github.com/apache/pulsar-client-go/pulsar"
30-
cliutils "github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
30+
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
3131
"github.com/mark3labs/mcp-go/mcp"
3232
"github.com/streamnative/streamnative-mcp-server/pkg/schema"
3333
)
@@ -259,20 +259,20 @@ func (fi *FunctionInvoker) unregisterResultChannel(messageID string) {
259259

260260
func isCorrelationInputTopic(correlationInputTopic string, inputTopic string) bool {
261261
// remove the partition index from the input topic
262-
if strings.Contains(correlationInputTopic, cliutils.PARTITIONEDTOPICSUFFIX) {
263-
correlationInputTopic = strings.Split(correlationInputTopic, cliutils.PARTITIONEDTOPICSUFFIX)[0]
262+
if strings.Contains(correlationInputTopic, utils.PARTITIONEDTOPICSUFFIX) {
263+
correlationInputTopic = strings.Split(correlationInputTopic, utils.PARTITIONEDTOPICSUFFIX)[0]
264264
}
265265

266266
// remove the partition index from the input topic
267-
if strings.Contains(inputTopic, cliutils.PARTITIONEDTOPICSUFFIX) {
268-
inputTopic = strings.Split(inputTopic, cliutils.PARTITIONEDTOPICSUFFIX)[0]
267+
if strings.Contains(inputTopic, utils.PARTITIONEDTOPICSUFFIX) {
268+
inputTopic = strings.Split(inputTopic, utils.PARTITIONEDTOPICSUFFIX)[0]
269269
}
270270

271-
correlationInputTopicName, err := cliutils.GetTopicName(correlationInputTopic)
271+
correlationInputTopicName, err := utils.GetTopicName(correlationInputTopic)
272272
if err != nil {
273273
return false
274274
}
275-
inputTopicName, err := cliutils.GetTopicName(inputTopic)
275+
inputTopicName, err := utils.GetTopicName(inputTopic)
276276
if err != nil {
277277
return false
278278
}

pkg/mcp/pftools/manager.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/admin/config"
3131
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/rest"
3232
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
33-
cliutils "github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
3433
"github.com/google/go-cmp/cmp"
3534
"github.com/mark3labs/mcp-go/mcp"
3635
"github.com/mark3labs/mcp-go/server"
@@ -50,7 +49,7 @@ var DefaultStringSchemaInfo = &SchemaInfo{
5049
Definition: map[string]interface{}{
5150
"type": "string",
5251
},
53-
PulsarSchemaInfo: &cliutils.SchemaInfo{
52+
PulsarSchemaInfo: &utils.SchemaInfo{
5453
Type: "STRING",
5554
},
5655
}

pkg/mcp/pftools/schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"fmt"
2323

2424
"github.com/apache/pulsar-client-go/pulsar"
25-
cliutils "github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
25+
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
2626
"github.com/mark3labs/mcp-go/mcp"
2727
"github.com/streamnative/pulsarctl/pkg/cmdutils"
2828
)
@@ -42,7 +42,7 @@ func GetSchemaFromTopic(admin cmdutils.Client, topic string) (*SchemaInfo, error
4242
if admin == nil {
4343
return nil, fmt.Errorf("failed to get schema from topic '%s': mcp server is not initialized", topic)
4444
}
45-
topicName, err := cliutils.GetTopicName(topic)
45+
topicName, err := utils.GetTopicName(topic)
4646
if err != nil {
4747
return nil, fmt.Errorf("failed to get topic name from topic '%s': %w", topic, err)
4848
}

0 commit comments

Comments
 (0)