MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / create_topic

Method create_topic

nodedb/src/control/pubsub.rs:146–157  ·  view source on GitHub ↗

Create a new topic.

(&self, name: &str)

Source from the content-addressed store, hash-verified

144
145 /// Create a new topic.
146 pub fn create_topic(&self, name: &str) -> Result<(), TopicError> {
147 let mut topics = super::lock_utils::write_or_recover(self.topics.write(), "topics");
148 if topics.contains_key(name) {
149 return Err(TopicError::AlreadyExists(name.to_string()));
150 }
151 topics.insert(
152 name.to_string(),
153 Mutex::new(Topic::new(self.default_max_messages)),
154 );
155 debug!(topic = name, "topic created");
156 Ok(())
157 }
158
159 /// Drop a topic and all its messages.
160 pub fn drop_topic(&self, name: &str) -> Result<(), TopicError> {

Callers 7

subscribe_with_backlogFunction · 0.80
drop_topicFunction · 0.80
bounded_message_logFunction · 0.80
topic_stats_testFunction · 0.80
consumer_group_statsFunction · 0.80
create_topicFunction · 0.80

Calls 4

write_or_recoverFunction · 0.85
to_stringMethod · 0.80
writeMethod · 0.45
insertMethod · 0.45

Tested by 5

subscribe_with_backlogFunction · 0.64
drop_topicFunction · 0.64
bounded_message_logFunction · 0.64
topic_stats_testFunction · 0.64
consumer_group_statsFunction · 0.64