Create a new topic.
(&self, name: &str)
| 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> { |