Skip to content

Commit 122fd01

Browse files
authored
Refactor Pulsar client initialization in pftools (#51)
1 parent c3063b8 commit 122fd01

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

pkg/mcp/pftools/manager.go

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

2929
pulsarclient "github.com/apache/pulsar-client-go/pulsar"
30-
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/admin/config"
3130
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/rest"
3231
"github.com/apache/pulsar-client-go/pulsaradmin/pkg/utils"
3332
"github.com/google/go-cmp/cmp"
3433
"github.com/mark3labs/mcp-go/mcp"
3534
"github.com/mark3labs/mcp-go/server"
36-
"github.com/streamnative/pulsarctl/pkg/cmdutils"
3735
"github.com/streamnative/streamnative-mcp-server/pkg/kafka"
3836
"github.com/streamnative/streamnative-mcp-server/pkg/pulsar"
3937
"github.com/streamnative/streamnative-mcp-server/pkg/schema"
@@ -75,8 +73,16 @@ func NewPulsarFunctionManager(snServer *Server, readOnly bool, options *ManagerO
7573
return nil, fmt.Errorf("failed to get Pulsar client: %w", err)
7674
}
7775

78-
adminClient := cmdutils.NewPulsarClientWithAPIVersion(config.V3)
79-
v2adminClient := cmdutils.NewPulsarClientWithAPIVersion(config.V2)
76+
adminClient, err := snServer.PulsarSession.GetAdminV3Client()
77+
if err != nil {
78+
return nil, fmt.Errorf("failed to get Pulsar admin v3 client: %w", err)
79+
}
80+
81+
v2adminClient, err := snServer.PulsarSession.GetAdminClient()
82+
if err != nil {
83+
return nil, fmt.Errorf("failed to get Pulsar admin client: %w", err)
84+
}
85+
8086
if options == nil {
8187
options = DefaultManagerOptions()
8288
}

0 commit comments

Comments
 (0)