Clippy lints, dashmap for breakers

This commit is contained in:
Aode (lion)
2021-11-23 16:19:59 -06:00
parent e1c61d5b5f
commit 1dba31e3a0
18 changed files with 74 additions and 101 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ impl QueryContact {
.await?;
let (username, display_name, url, avatar) =
to_contact(contact).ok_or_else(|| ErrorKind::Extract("contact"))?;
to_contact(contact).ok_or(ErrorKind::Extract("contact"))?;
state
.node_cache
+3 -3
View File
@@ -51,18 +51,18 @@ impl QueryInstance {
.await?;
let description = if instance.description.is_empty() {
instance.short_description.unwrap_or(String::new())
instance.short_description.unwrap_or_default()
} else {
instance.description
};
if let Some(mut contact) = instance.contact {
let uuid = if let Some(uuid) = state.media.get_uuid(contact.avatar.clone()).await? {
contact.avatar = state.config.generate_url(UrlKind::Media(uuid)).into();
contact.avatar = state.config.generate_url(UrlKind::Media(uuid));
uuid
} else {
let uuid = state.media.store_url(contact.avatar.clone()).await?;
contact.avatar = state.config.generate_url(UrlKind::Media(uuid)).into();
contact.avatar = state.config.generate_url(UrlKind::Media(uuid));
uuid
};
-6
View File
@@ -15,7 +15,6 @@ pub(crate) use self::{
use crate::{
config::Config,
data::{ActorCache, MediaCache, NodeCache, State},
db::Db,
error::{Error, ErrorKind},
jobs::process_listeners::Listeners,
requests::Requests,
@@ -24,7 +23,6 @@ use background_jobs::{memory_storage::Storage, Job, QueueHandle, WorkerConfig};
use std::time::Duration;
pub(crate) fn create_workers(
db: Db,
state: State,
actors: ActorCache,
media: MediaCache,
@@ -32,7 +30,6 @@ pub(crate) fn create_workers(
) -> JobServer {
let queue_handle = WorkerConfig::new(Storage::new(), move |queue_handle| {
JobState::new(
db.clone(),
state.clone(),
actors.clone(),
JobServer::new(queue_handle),
@@ -62,7 +59,6 @@ pub(crate) fn create_workers(
#[derive(Clone, Debug)]
pub(crate) struct JobState {
db: Db,
requests: Requests,
state: State,
actors: ActorCache,
@@ -87,7 +83,6 @@ impl std::fmt::Debug for JobServer {
impl JobState {
fn new(
db: Db,
state: State,
actors: ActorCache,
job_server: JobServer,
@@ -97,7 +92,6 @@ impl JobState {
JobState {
requests: state.requests(&config),
node_cache: state.node_cache(),
db,
actors,
config,
media,
+3 -5
View File
@@ -66,7 +66,8 @@ impl QueryNodeinfo {
if let Some(contact_id) = accounts.get(0) {
state
.job_server
.queue(QueryContact::new(self.actor_id, contact_id.clone())).await?;
.queue(QueryContact::new(self.actor_id, contact_id.clone()))
.await?;
}
}
@@ -129,10 +130,7 @@ enum MaybeSupported<T> {
impl<T> MaybeSupported<T> {
fn is_supported(&self) -> bool {
match self {
MaybeSupported::Supported(_) => true,
_ => false,
}
matches!(self, MaybeSupported::Supported(_))
}
}