This is an automated email from the ASF dual-hosted git repository.
zixuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new 9f5ea523 feat(namespace): add RemovePersistence methods to namespace
admin (#1447)
9f5ea523 is described below
commit 9f5ea523c4dac25941b7c9bf7c7511b06981d1c0
Author: Rui Fu <[email protected]>
AuthorDate: Mon Dec 15 11:34:34 2025 +0800
feat(namespace): add RemovePersistence methods to namespace admin (#1447)
---
pulsaradmin/pkg/admin/namespace.go | 19 +++++++++++++++++++
pulsaradmin/pkg/admin/namespace_test.go | 8 ++++++++
2 files changed, 27 insertions(+)
diff --git a/pulsaradmin/pkg/admin/namespace.go
b/pulsaradmin/pkg/admin/namespace.go
index d5d33f12..1d24b5c5 100644
--- a/pulsaradmin/pkg/admin/namespace.go
+++ b/pulsaradmin/pkg/admin/namespace.go
@@ -396,6 +396,12 @@ type Namespaces interface {
// SetPersistenceWithContext sets the persistence configuration for all
the topics on a namespace
SetPersistenceWithContext(ctx context.Context, namespace string,
persistence utils.PersistencePolicies) error
+ // RemovePersistence removes the persistence configuration for a
namespace
+ RemovePersistence(namespace string) error
+
+ // RemovePersistenceWithContext removes the persistence configuration
for a namespace
+ RemovePersistenceWithContext(ctx context.Context, namespace string)
error
+
// GetPersistence returns the persistence configuration for a namespace.
// Returns nil if the persistence policy is not configured at the
namespace level.
GetPersistence(namespace string) (*utils.PersistencePolicies, error)
@@ -1433,6 +1439,19 @@ func (n *namespaces) SetPersistenceWithContext(
return n.pulsar.Client.PostWithContext(ctx, endpoint, &persistence)
}
+func (n *namespaces) RemovePersistence(namespace string) error {
+ return n.RemovePersistenceWithContext(context.Background(), namespace)
+}
+
+func (n *namespaces) RemovePersistenceWithContext(ctx context.Context,
namespace string) error {
+ nsName, err := utils.GetNamespaceName(namespace)
+ if err != nil {
+ return err
+ }
+ endpoint := n.pulsar.endpoint(n.basePath, nsName.String(),
"persistence")
+ return n.pulsar.Client.DeleteWithContext(ctx, endpoint)
+}
+
func (n *namespaces) SetBookieAffinityGroup(namespace string,
bookieAffinityGroup utils.BookieAffinityGroupData) error {
return n.SetBookieAffinityGroupWithContext(context.Background(),
namespace, bookieAffinityGroup)
}
diff --git a/pulsaradmin/pkg/admin/namespace_test.go
b/pulsaradmin/pkg/admin/namespace_test.go
index 1ca235f5..1796598e 100644
--- a/pulsaradmin/pkg/admin/namespace_test.go
+++ b/pulsaradmin/pkg/admin/namespace_test.go
@@ -861,4 +861,12 @@ func TestNamespaces_Persistence(t *testing.T) {
assert.NotNil(t, persistence, "Expected non-nil when persistence is
configured")
assert.Equal(t, 1, persistence.BookkeeperEnsemble)
assert.Equal(t, 1, persistence.BookkeeperWriteQuorum)
+
+ // Remove persistence policy - should return nil
+ err = admin.Namespaces().RemovePersistence(namespaceName)
+ assert.NoError(t, err)
+
+ persistence, err = admin.Namespaces().GetPersistence(namespaceName)
+ assert.NoError(t, err)
+ assert.Nil(t, persistence, "Expected nil after removing persistence
configuration")
}