diff options
author | Ashelyn Rose <git@ashen.earth> | 2024-10-07 21:40:31 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-10-07 21:40:31 -0600 |
commit | a5d44de5c4cac9d266b7f24784c53e5e667b0991 (patch) | |
tree | 257d5cec308e19d027d14e7af023da9a09d96f20 /src | |
parent | 9da2bb7561210ace25ea7cabbb455d0abc26dbe9 (diff) |
Handle case where system has no members
Diffstat (limited to 'src')
-rw-r--r-- | src/system/aggregator.rs | 5 | ||||
-rw-r--r-- | src/system/mod.rs | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/src/system/aggregator.rs b/src/system/aggregator.rs index 8fbdfdd..52b1a8c 100644 --- a/src/system/aggregator.rs +++ b/src/system/aggregator.rs @@ -20,13 +20,14 @@ pub struct MessageAggregator { impl MessageAggregator { pub fn new(system_size: usize) -> Self { - let (tx, rx) = channel::<MessageEvent>(system_size * 2); + let buf_size = std::cmp::max(system_size * 2, 1); + let (tx, rx) = channel::<MessageEvent>(buf_size); Self { state: Arc::new(RwLock::new( AggregatorState { tx, rx, - message_cache: LruCache::new(NonZeroUsize::new(system_size * 2).unwrap()), + message_cache: LruCache::new(NonZeroUsize::new(buf_size).unwrap()), system_emitter: None, })) diff --git a/src/system/mod.rs b/src/system/mod.rs index d993731..44c6da8 100644 --- a/src/system/mod.rs +++ b/src/system/mod.rs @@ -82,6 +82,10 @@ impl Manager { self.start_bot(member_id).await; } + if self.config.members.len() < 1 { + println!("WARNING: System {} has no configured members", &self.name); + } + loop { match system_receiver.recv().await { Some(SystemEvent::GatewayConnected(member_id, user_id)) => { |