chore: rename data managers to just managers

This commit is contained in:
2026-05-28 00:50:20 -04:00
parent b5a56b1273
commit 862a333131
21 changed files with 82 additions and 82 deletions

View File

@@ -7,11 +7,11 @@ use snafu::{ResultExt as _, Snafu};
use crate::{OperatorExt, bot_capnp, option_ext::OptionExt as _};
#[derive(Debug, Clone)]
pub struct BotDataManager {
pub struct BotManager {
operator: Operator,
}
impl BotDataManager {
impl BotManager {
pub fn new(operator: Operator) -> Self {
Self { operator }
}
@@ -32,7 +32,7 @@ pub enum WithError {
DeserializeError { source: capnp::Error },
}
impl BotDataManager {
impl BotManager {
pub async fn with<R>(
&self,
f: impl FnOnce(bot_capnp::bot::Reader<'_>) -> R,
@@ -101,7 +101,7 @@ pub enum UpdateError {
FinalizeError { source: std::io::Error },
}
impl BotDataManager {
impl BotManager {
pub async fn update<R>(
&self,
f: impl FnOnce(bot_capnp::bot::Builder<'_>) -> R,

View File

@@ -1,7 +1,7 @@
use crate::{
OneToManyUniqueBTreeMap, UserDataManager,
OneToManyUniqueBTreeMap, UserManager,
option_ext::OptionExt as _,
recording_data::{Clip, Recording, RecordingData, RecordingDataManager},
recording_data::{Clip, Recording, RecordingData, RecordingManager},
user_capnp::user::Consent,
user_data::RECORD_IF_CONSENT_UNSPECIFIED,
};
@@ -26,7 +26,7 @@ struct Handler {
start_instant: Instant,
start_utc: UtcDateTime,
recording_data_manager: RecordingDataManager,
recording_manager: RecordingManager,
guild_id: Id<GuildMarker>,
channel_id: Id<ChannelMarker>,
@@ -36,7 +36,7 @@ struct Handler {
audio_channels: u16,
audio_sample_rate: u32,
user_data_manager: UserDataManager,
user_manager: UserManager,
}
#[async_trait]
@@ -73,7 +73,7 @@ impl EventHandler for Handler {
if let Some(pcm) = &voice_data.decoded_voice {
let may_record = user_id
.map_async(|user_id| {
self.user_data_manager
self.user_manager
.with(user_id, |user_data| {
user_data.get_voice_recording_consent().unwrap()
})
@@ -133,7 +133,7 @@ impl EventHandler for Handler {
tracing::info!("going to write the audio shortly");
let recording_data_manager = self.recording_data_manager.clone();
let recording_manager = self.recording_manager.clone();
let samples = pcm.clone();
let recording_data = RecordingData {
@@ -143,7 +143,7 @@ impl EventHandler for Handler {
};
tokio::spawn(async move {
recording_data_manager
recording_manager
.write(&recording, recording_data)
.await
.expect("TODO");
@@ -175,9 +175,9 @@ pub async fn join_and_record(
audio_channels: Channels,
audio_sample_rate: SampleRate,
guild_id: Id<GuildMarker>,
recording_data_manager: RecordingDataManager,
recording_manager: RecordingManager,
songbird: &Songbird,
user_data_manager: UserDataManager,
user_manager: UserManager,
voice_channel_id: Id<ChannelMarker>,
) -> Result<(), songbird::error::JoinError> {
let start_instant = Instant::now();
@@ -190,7 +190,7 @@ pub async fn join_and_record(
let handler = Handler {
start_instant,
start_utc,
recording_data_manager,
recording_manager,
guild_id,
channel_id: voice_channel_id,
known_ssrcs: Default::default(),
@@ -198,7 +198,7 @@ pub async fn join_and_record(
audio_channels,
audio_sample_rate,
user_data_manager,
user_manager,
};
let call = songbird.get_or_insert(guild_id);

View File

@@ -88,7 +88,7 @@ pub async fn handle(state: State, interaction: Interaction) {
if is_bot_owner {
let heat_script_description = state
.bot_data_manager
.bot_manager
.with(|bot_data| {
let heat_script_option = bot_data.has_heat_script().then(|| {
bot_data
@@ -118,11 +118,11 @@ pub async fn handle(state: State, interaction: Interaction) {
.await
.expect("TODO");
let mut user_id_stream = state.user_data_manager.list().await.expect("TODO");
let mut user_id_stream = state.user_manager.list().await.expect("TODO");
while let Some(user_id) = user_id_stream.try_next().await.expect("TODO") {
let (consent, notification_script) = state
.user_data_manager
.user_manager
.with(user_id, |user_data| {
let consent = user_data.get_voice_recording_consent().unwrap();
let notification_script = user_data.has_notification_script().then_some(

View File

@@ -123,9 +123,9 @@ pub async fn handle(state: State, interaction: Interaction) {
.audio_channels(state.audio_channels)
.audio_sample_rate(state.audio_sample_rate)
.guild_id(guild_id)
.recording_data_manager(state.recording_data_manager)
.recording_manager(state.recording_manager)
.songbird(&state.songbird)
.user_data_manager(state.user_data_manager)
.user_manager(state.user_manager)
.voice_channel_id(voice_channel_id)
.call()
.await

View File

@@ -16,8 +16,8 @@ use twilight_model::{
};
use crate::{
BotDataManager, GuildVoiceChannelToTextChannel, UserDataManager, VCsSender,
recording_data::RecordingDataManager, render_data::RenderDataManager,
BotManager, GuildVoiceChannelToTextChannel, UserManager, VCsSender,
recording_data::RecordingManager, render_data::RenderManager,
};
pub mod info;
@@ -31,7 +31,7 @@ pub mod render;
pub struct State {
pub audio_channels: Channels,
pub audio_sample_rate: SampleRate,
pub bot_data_manager: BotDataManager,
pub bot_manager: BotManager,
pub cancellation_token: CancellationToken,
pub discord_application_id: Id<ApplicationMarker>,
pub discord_bot_owner_user_id: Id<UserMarker>,
@@ -44,10 +44,10 @@ pub struct State {
pub discord_opt_out_command_name: Arc<str>,
pub discord_user_id: Id<UserMarker>,
pub discord_voice_channel_corresponding_text_channel: Arc<GuildVoiceChannelToTextChannel>,
pub recording_data_manager: RecordingDataManager,
pub render_data_manager: RenderDataManager,
pub recording_manager: RecordingManager,
pub render_manager: RenderManager,
pub songbird: Arc<Songbird>,
pub user_data_manager: UserDataManager,
pub user_manager: UserManager,
pub vcs_sender: VCsSender,
}

View File

@@ -54,7 +54,7 @@ pub async fn handle(state: State, interaction: Interaction) {
};
let previous_consent = state
.user_data_manager
.user_manager
.update(user_id, |mut user_data| {
let previous_consent = user_data
.reborrow()

View File

@@ -54,7 +54,7 @@ pub async fn handle(state: State, interaction: Interaction) {
};
let previous_consent = state
.user_data_manager
.user_manager
.update(user_id, |mut user_data| {
let previous_consent = user_data
.reborrow()

View File

@@ -296,13 +296,13 @@ pub async fn handle(state: State, interaction: Interaction) {
let mut recordings =
state
.recording_data_manager
.recording_manager
.between_in_vc(start, end, guild_id, voice_channel_id);
while let Some(recording) = recordings.try_next().await.expect("TODO") {
tracing::debug!(?recording);
let recording_data = state
.recording_data_manager
.recording_manager
.read(&recording)
.await
.expect("TODO");

View File

@@ -12,7 +12,7 @@ use twilight_model::id::{
use twilight_util::builder::embed::EmbedBuilder;
use crate::{
BotDataManager, OneToManyUniqueBTreeMap, State, UserInVCData, bot_data,
BotManager, OneToManyUniqueBTreeMap, State, UserInVCData, bot_data,
call::join_and_record,
track_vcs::VCsInGuild,
vc_user::{Camera, Headphone, Microphone, Stream},
@@ -41,7 +41,7 @@ pub async fn heat_seek(state: State) {
tokio::spawn(
evaluate_heat()
.bot_data_manager(state.bot_data_manager.clone())
.bot_manager(state.bot_manager.clone())
.bot_owner_user_id(state.discord_bot_owner_user_id)
.bot_user_id(state.discord_user_id)
.cancellation_token(state.cancellation_token.clone())
@@ -110,9 +110,9 @@ async fn get_heat(
users_in_vc: &BTreeMap<Id<UserMarker>, UserInVCData>,
bot_user_id: Id<UserMarker>,
bot_owner_user_id: Id<UserMarker>,
bot_data_manager: &BotDataManager,
bot_manager: &BotManager,
) -> Result<Heat, GetHeatError> {
let heat_script = bot_data_manager
let heat_script = bot_manager
.with(|bot_data| {
bot_data.has_heat_script().then(|| {
bot_data
@@ -185,7 +185,7 @@ async fn get_heat(
#[bon::builder]
#[tracing::instrument(skip(vcs_in_guild_watcher, channel_heat_sender))]
async fn evaluate_heat(
bot_data_manager: BotDataManager,
bot_manager: BotManager,
bot_owner_user_id: Id<UserMarker>,
bot_user_id: Id<UserMarker>,
cancellation_token: CancellationToken,
@@ -199,12 +199,12 @@ async fn evaluate_heat(
let channel_heat_results: BTreeMap<_, _> = {
FuturesUnordered::from_iter((&*vcs_in_guild).into_iter().map(
|(&channel_id, users_in_vc)| {
let bot_data_manager = bot_data_manager.clone();
let bot_manager = bot_manager.clone();
async move {
(
channel_id,
get_heat()
.bot_data_manager(&bot_data_manager)
.bot_manager(&bot_manager)
.bot_owner_user_id(bot_owner_user_id)
.bot_user_id(bot_user_id)
.users_in_vc(users_in_vc)
@@ -326,9 +326,9 @@ async fn follow_hottest_vc(
.audio_channels(state.audio_channels)
.audio_sample_rate(state.audio_sample_rate)
.guild_id(guild_id)
.recording_data_manager(state.recording_data_manager.clone())
.recording_manager(state.recording_manager.clone())
.songbird(&state.songbird)
.user_data_manager(state.user_data_manager.clone())
.user_manager(state.user_manager.clone())
.voice_channel_id(hottest_vc)
.call()
.await

View File

@@ -17,16 +17,16 @@ capnp::generated_code!(mod bot_capnp);
capnp::generated_code!(mod user_capnp);
shadow_rs::shadow!(build_info);
pub use bot_data::BotDataManager;
pub use bot_data::BotManager;
pub use command::{Router as CommandRouter, State, all as all_commands};
pub use heat_seek::heat_seek;
pub use one_to_many::OneToManyUniqueBTreeMap;
pub use one_to_many_with_data::OneToManyUniqueBTreeMapWithData;
pub use one_to_one::OneToOneBTreeMap;
pub use operator_ext::OperatorExt;
pub use recording_data::RecordingDataManager;
pub use render_data::RenderDataManager;
pub use recording_data::RecordingManager;
pub use render_data::RenderManager;
pub use storage::Storage;
pub use track_vcs::{GuildVoiceChannelToTextChannel, VCs, VCsSender, initialize_vcs, update_vcs};
pub use user_data::UserDataManager;
pub use user_data::UserManager;
pub use vc_user::{UserInVCData, VoiceStatus};

View File

@@ -1,8 +1,8 @@
use clap::Parser;
use fomo_reducer::{
BotDataManager, CommandRouter, GuildVoiceChannelToTextChannel, RecordingDataManager,
RenderDataManager, State, Storage, UserDataManager, VCsSender, all_commands, command,
heat_seek, initialize_vcs, update_vcs,
BotManager, CommandRouter, GuildVoiceChannelToTextChannel, RecordingManager, RenderManager,
State, Storage, UserManager, VCsSender, all_commands, command, heat_seek, initialize_vcs,
update_vcs,
};
use secrecy::{ExposeSecret, SecretString};
use snafu::{OptionExt, ResultExt, Snafu};
@@ -348,10 +348,10 @@ async fn main() -> Result<(), MainError> {
let render_data = render_data.into_inner();
let user_data = user_data.into_inner();
let bot_data_manager = BotDataManager::new(bot_data);
let recording_data_manager = RecordingDataManager::new(recording_data);
let render_data_manager = RenderDataManager::new(render_data);
let user_data_manager = UserDataManager::new(user_data);
let bot_manager = BotManager::new(bot_data);
let recording_manager = RecordingManager::new(recording_data);
let render_manager = RenderManager::new(render_data);
let user_manager = UserManager::new(user_data);
let discord_voice_channel_corresponding_text_channel = {
let mut map = GuildVoiceChannelToTextChannel::default();
@@ -372,7 +372,7 @@ async fn main() -> Result<(), MainError> {
let state = State {
audio_channels,
audio_sample_rate,
bot_data_manager,
bot_manager,
cancellation_token: cancellation_token.clone(),
discord_application_id,
discord_bot_owner_user_id,
@@ -385,10 +385,10 @@ async fn main() -> Result<(), MainError> {
discord_opt_out_command_name,
discord_user_id,
discord_voice_channel_corresponding_text_channel,
recording_data_manager,
render_data_manager,
recording_manager,
render_manager,
songbird,
user_data_manager,
user_manager,
vcs_sender,
};

View File

@@ -6,7 +6,7 @@ use twilight_model::id::{
marker::{ChannelMarker, GuildMarker},
};
use super::{ClipEntryError, ListError, Recording, RecordingDataManager};
use super::{ClipEntryError, ListError, Recording, RecordingManager};
const BUFFER_SIZE: usize = 2048;
@@ -19,7 +19,7 @@ pub enum RecordingEntryError {
ClipEntryError { source: ClipEntryError },
}
impl RecordingDataManager {
impl RecordingManager {
pub fn between(
&self,
start: UtcDateTime,
@@ -141,7 +141,7 @@ impl RecordingDataManager {
}
}
impl RecordingDataManager {
impl RecordingManager {
pub fn between_in_vc(
&self,
start: UtcDateTime,

View File

@@ -4,7 +4,7 @@ use std::{fmt::Display, str::FromStr};
use super::{
CreateListerSnafu, Day, Guild, Hour, ListError, Microsecond, Minute, Month,
RecordingDataManager, Second, User, VoiceChannel, Year, guild, microsecond, second, user,
RecordingManager, Second, User, VoiceChannel, Year, guild, microsecond, second, user,
voice_channel,
};
@@ -89,7 +89,7 @@ pub enum ClipEntryError {
ParseError { source: TakeError },
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn clips(
&self,
year: Year,

View File

@@ -2,7 +2,7 @@ use futures::{TryStream, TryStreamExt as _};
use snafu::{OptionExt as _, ResultExt as _, Snafu};
use std::num::ParseIntError;
use super::{CreateListerSnafu, ListError, Month, RecordingDataManager, Year};
use super::{CreateListerSnafu, ListError, Month, RecordingManager, Year};
pub type Day = u8;
@@ -32,7 +32,7 @@ pub enum DayEntryError {
ParseError { source: TakeError },
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn days(
&self,
year: Year,

View File

@@ -2,7 +2,7 @@ use futures::{TryStream, TryStreamExt as _};
use snafu::{OptionExt as _, ResultExt as _, Snafu};
use std::num::ParseIntError;
use super::{CreateListerSnafu, Day, ListError, Month, RecordingDataManager, Year};
use super::{CreateListerSnafu, Day, ListError, Month, RecordingManager, Year};
pub type Hour = u8;
@@ -32,7 +32,7 @@ pub enum HourEntryError {
ParseError { source: TakeError },
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn hours(
&self,
year: Year,

View File

@@ -2,7 +2,7 @@ use futures::{TryStream, TryStreamExt as _};
use snafu::{OptionExt as _, ResultExt as _, Snafu};
use std::num::ParseIntError;
use super::{CreateListerSnafu, Day, Hour, ListError, Month, RecordingDataManager, Year};
use super::{CreateListerSnafu, Day, Hour, ListError, Month, RecordingManager, Year};
pub type Minute = u8;
@@ -32,7 +32,7 @@ pub enum MinuteEntryError {
ParseError { source: TakeError },
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn minutes(
&self,
year: Year,

View File

@@ -33,11 +33,11 @@ use voice_channel::VoiceChannel;
use year::Year;
#[derive(Debug, Clone)]
pub struct RecordingDataManager {
pub struct RecordingManager {
operator: Operator,
}
impl RecordingDataManager {
impl RecordingManager {
pub fn new(operator: Operator) -> Self {
Self { operator }
}
@@ -50,7 +50,7 @@ pub struct RecordingData {
pub samples: Vec<i16>,
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn write(
&self,
recording: &Recording,
@@ -92,7 +92,7 @@ impl RecordingDataManager {
}
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn read(
&self,
recording: &Recording,

View File

@@ -1,7 +1,7 @@
use futures::{TryStream, TryStreamExt as _};
use snafu::{OptionExt as _, ResultExt as _, Snafu};
use super::{CreateListerSnafu, ListError, RecordingDataManager, Year};
use super::{CreateListerSnafu, ListError, RecordingManager, Year};
pub use time::Month;
@@ -31,7 +31,7 @@ pub enum MonthEntryError {
ParseError { source: TakeError },
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn months(
&self,
year: Year,

View File

@@ -2,7 +2,7 @@ use futures::{TryStream, TryStreamExt as _};
use snafu::{OptionExt as _, ResultExt as _, Snafu};
use std::num::ParseIntError;
use super::{CreateListerSnafu, ListError, RecordingDataManager};
use super::{CreateListerSnafu, ListError, RecordingManager};
pub type Year = i32;
@@ -32,7 +32,7 @@ pub enum YearEntryError {
ParseError { source: TakeError },
}
impl RecordingDataManager {
impl RecordingManager {
pub async fn years(
&self,
) -> Result<impl TryStream<Ok = Year, Error = YearEntryError> + Unpin, ListError> {

View File

@@ -1,11 +1,11 @@
use opendal::Operator;
#[derive(Debug, Clone)]
pub struct RenderDataManager {
pub struct RenderManager {
operator: Operator,
}
impl RenderDataManager {
impl RenderManager {
pub fn new(operator: Operator) -> Self {
Self { operator }
}

View File

@@ -14,12 +14,12 @@ use crate::{OperatorExt, option_ext::OptionExt as _, user_capnp};
pub const RECORD_IF_CONSENT_UNSPECIFIED: bool = true;
#[derive(Debug, Clone)]
pub struct UserDataManager {
pub struct UserManager {
operator: Operator,
cache: Cache<Id<UserMarker>, Bytes>,
}
impl UserDataManager {
impl UserManager {
pub fn new(operator: Operator) -> Self {
Self {
operator,
@@ -83,7 +83,7 @@ pub enum EntryError {
ParsePathError { source: ParsePathError },
}
impl UserDataManager {
impl UserManager {
pub async fn list(
&self,
) -> Result<impl TryStream<Ok = Id<UserMarker>, Error = EntryError> + Unpin, ListError> {
@@ -111,7 +111,7 @@ pub enum ReadError {
DecompressionError { source: std::io::Error },
}
impl UserDataManager {
impl UserManager {
async fn read(&self, id: Id<UserMarker>) -> Result<Bytes, ReadError> {
self.cache
.try_get_with::<_, ReadError>(id, async {
@@ -168,7 +168,7 @@ pub enum WriteError {
FinalizeError { source: std::io::Error },
}
impl UserDataManager {
impl UserManager {
async fn write(&self, id: Id<UserMarker>, bytes: Bytes) -> Result<(), WriteError> {
let path = path(id);
@@ -207,7 +207,7 @@ pub enum WithError {
DeserializeError { source: capnp::Error },
}
impl UserDataManager {
impl UserManager {
pub async fn with<R>(
&self,
id: Id<UserMarker>,
@@ -245,7 +245,7 @@ pub enum UpdateError {
WriteError { source: WriteError },
}
impl UserDataManager {
impl UserManager {
pub async fn update<R>(
&self,
id: Id<UserMarker>,