// Destroy a DTopic from the cluster. It stops background goroutines and releases underlying data structures.
Destroy a DTopic from the cluster. It stops background goroutines and releases underlying data structures.
// Destroy a DTopic from the cluster . It stops background goroutines and releases underlying data structures .
func (dt *DTopic) Destroy() error {
	req := protocol.NewDTopicMessage(protocol.OpDTopicDestroy)
	req.SetDTopic(dt.name)
	resp, err := dt.request(req)
	if err != nil {
		return err
	}
	err = checkStatusCode(resp)
	if err != nil {
		return err
	}
	dt.mu.Lock()
	defer dt.mu.Unlock()
	for listenerID := range dt.listeners {
		err = dt.removeStreamListener(listenerID)
		if err != nil {
			logger.Printf("[ERROR] Failed to remove listener: %d: %v\n", listenerID, err)
			continue
		}
	}
	for listenerID := range dt.listeners {
		delete(dt.listeners, listenerID)
	}
	return nil
}
func ( dt * DTopic ) Destroy ( ) error { req := protocol . NewDTopicMessage ( protocol . OpDTopicDestroy ) req . SetDTopic ( dt . name ) resp , err := dt . request ( req ) if err != nil { return err } err = checkStatusCode ( resp ) if err != nil { return err } dt . mu . Lock ( ) defer dt . mu . Unlock ( ) for listenerID := range dt . listeners { err = dt . removeStreamListener ( listenerID ) if err != nil { logger . Printf ( " \n " , listenerID , err ) continue } } for listenerID := range dt . listeners { delete ( dt . listeners , listenerID ) } return nil }
Destroy a DTopic from the cluster.
Destroy a DTopic from the cluster .
// Remove local listeners // I don't know that it's good to remove the map items while iterating over the same map.