MCPcopy Create free account
hub / github.com/apache/kvrocks-controller / RemoveNamespace

Method RemoveNamespace

store/store.go:110–130  ·  view source on GitHub ↗

RemoveNamespace delete the specified namespace from store

(ctx context.Context, ns string)

Source from the content-addressed store, hash-verified

108
109// RemoveNamespace delete the specified namespace from store
110func (s *ClusterStore) RemoveNamespace(ctx context.Context, ns string) error {
111 if has, _ := s.ExistsNamespace(ctx, ns); !has {
112 return consts.ErrNotFound
113 }
114 clusters, err := s.ListCluster(ctx, ns)
115 if err != nil {
116 return err
117 }
118 if len(clusters) != 0 {
119 return fmt.Errorf("%w: please delete clusters first", consts.ErrForbidden)
120 }
121 if err := s.e.Delete(ctx, appendPrefix(ns)); err != nil {
122 return err
123 }
124 s.EmitEvent(EventPayload{
125 Namespace: ns,
126 Type: EventNamespace,
127 Command: CommandRemove,
128 })
129 return nil
130}
131
132func (s *ClusterStore) getLock(ns, cluster string) *sync.RWMutex {
133 value, _ := s.locks.LoadOrStore(fmt.Sprintf("%s/%s", ns, cluster), &sync.RWMutex{})

Callers 1

TestClusterStoreFunction · 0.95

Calls 6

ExistsNamespaceMethod · 0.95
ListClusterMethod · 0.95
EmitEventMethod · 0.95
appendPrefixFunction · 0.85
ErrorfMethod · 0.80
DeleteMethod · 0.65

Tested by 1

TestClusterStoreFunction · 0.76