Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower dependency count #533

Merged
merged 9 commits into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
980 changes: 282 additions & 698 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ members = [
"lib/blowocking",
"lib/cursiv",
"lib/geomjeungja",
"lib/http-compat",
"lib/http-signatures",
"lib/just-retry",
"lib/masto-id-convert",
Expand Down Expand Up @@ -125,3 +124,15 @@ install-updater = true
[patch.crates-io]
diesel-async = { git = "https://github.com/weiznich/diesel_async.git", rev = "d02798c67065d763154d7272dd0c09b39757d0f2" }
scraper = { git = "https://github.com/causal-agent/scraper.git", rev = "d67111f5cc0b7da6e6ff10e4549d87cf09ba3e5b" }
tokio-postgres-rustls = { git = "https://github.com/jbg/tokio-postgres-rustls.git", rev = "b16c1bc0f5d4f91324174fd1bd839d743a70f86a" }

# Support XAUTOCLAIM
redis = { git = "https://github.com/redis-rs/redis-rs.git", rev = "0c544b548b52180acda8e8394ab21b2761497e50" }

# Patch to make OpenTelemetry with with hyper 1
opentelemetry = { git = "https://github.com/open-telemetry/opentelemetry-rust.git", rev = "b44cb130e4a102b0d676289e91c003f4b1008d08" }
opentelemetry-http = { git = "https://github.com/open-telemetry/opentelemetry-rust.git", rev = "b44cb130e4a102b0d676289e91c003f4b1008d08" }
opentelemetry-otlp = { git = "https://github.com/open-telemetry/opentelemetry-rust.git", rev = "b44cb130e4a102b0d676289e91c003f4b1008d08" }
opentelemetry_sdk = { git = "https://github.com/open-telemetry/opentelemetry-rust.git", rev = "b44cb130e4a102b0d676289e91c003f4b1008d08" }
tonic = { git = "https://github.com/hyperium/tonic.git", rev = "9b306af386528f11dbd022bc372d367adc4e96b5" }
tracing-opentelemetry = { git = "https://github.com/aumetra/tracing-opentelemetry.git", branch = "v0.1.x-http1" }
2 changes: 1 addition & 1 deletion crates/kitsune-cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license.workspace = true
[dependencies]
enum_dispatch = "0.3.13"
kitsune-error = { path = "../kitsune-error" }
moka = { version = "0.12.7", features = ["future"] }
moka = { version = "0.12.7", features = ["sync"] }
multiplex-pool = { path = "../../lib/multiplex-pool" }
redis = { version = "0.25.3", default-features = false, features = [
"connection-manager",
Expand Down
10 changes: 5 additions & 5 deletions crates/kitsune-cache/src/in_memory.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::CacheBackend;
use kitsune_error::Result;
use moka::future::Cache;
use moka::sync::Cache;
use std::{fmt::Display, marker::PhantomData, time::Duration};

pub struct InMemory<K, V>
Expand Down Expand Up @@ -36,16 +36,16 @@ where
V: Clone + Send + Sync + 'static,
{
async fn delete(&self, key: &K) -> Result<()> {
self.inner.remove(&key.to_string()).await;
self.inner.remove(&key.to_string());
Ok(())
}

async fn get(&self, key: &K) -> Result<Option<V>> {
Ok(self.inner.get(&key.to_string()).await)
Ok(self.inner.get(&key.to_string()))
}

async fn set(&self, key: &K, value: &V) -> Result<()> {
self.inner.insert(key.to_string(), value.clone()).await;
self.inner.insert(key.to_string(), value.clone());
Ok(())
}
}
Expand All @@ -70,7 +70,7 @@ mod test {
cache.set(&"hello", &"world").await.unwrap();
cache.set(&"another", &"pair").await.unwrap();

cache.inner.run_pending_tasks().await;
cache.inner.run_pending_tasks();

assert_eq!(cache.inner.entry_count(), 1);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-derive/impl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ proc-macro = true
[dependencies]
proc-macro2 = "1.0.82"
quote = "1.0.36"
syn = { version = "2.0.61", features = ["full"] }
syn = { version = "2.0.63", features = ["full"] }

[lints]
workspace = true
2 changes: 1 addition & 1 deletion crates/kitsune-observability/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license.workspace = true
async-trait = "0.1.80"
eyre = "0.6.12"
http-body-util = "0.1.1"
http-compat = { path = "../../lib/http-compat" }
hyper = { version = "1.3.1", default-features = false }
kitsune-config = { path = "../kitsune-config" }
kitsune-http-client = { path = "../kitsune-http-client" }
Expand All @@ -19,6 +18,7 @@ opentelemetry = { version = "0.22.0", default-features = false, features = [
opentelemetry-http = "0.11.1"
opentelemetry-otlp = { version = "0.15.0", default-features = false, features = [
"grpc-tonic",
"http-json",
"http-proto",
"tls",
"tls-roots",
Expand Down
5 changes: 2 additions & 3 deletions crates/kitsune-observability/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use async_trait::async_trait;
use eyre::WrapErr;
use http_body_util::BodyExt;
use http_compat::Compat;
use kitsune_config::{open_telemetry::Transport, Configuration};
use opentelemetry::trace::{noop::NoopTracer, Tracer};
use opentelemetry_http::{Bytes, HttpClient, HttpError, Request, Response};
Expand Down Expand Up @@ -34,12 +33,12 @@ impl HttpClient for HttpClientAdapter {
let (parts, body) = request.into_parts();
let request = Request::from_parts(parts, body.into());

let response = self.inner.execute(request.compat()).await?.into_inner();
let response = self.inner.execute(request).await?.into_inner();

let (parts, body) = response.into_parts();
let body = body.collect().await?.to_bytes();

Ok(hyper::http::Response::from_parts(parts, body).compat())
Ok(hyper::http::Response::from_parts(parts, body))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/kitsune-oidc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kitsune-config = { path = "../kitsune-config" }
kitsune-derive = { path = "../kitsune-derive" }
kitsune-error = { path = "../kitsune-error" }
kitsune-http-client = { path = "../kitsune-http-client" }
moka = { version = "0.12.7", features = ["future"] }
moka = { version = "0.12.7", features = ["sync"] }
multiplex-pool = { path = "../../lib/multiplex-pool" }
oauth2 = { version = "5.0.0-alpha.4", default-features = false }
once_cell = "1.19.0"
Expand Down
5 changes: 2 additions & 3 deletions crates/kitsune-oidc/src/state/store/in_memory.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Store;
use crate::state::LoginState;
use kitsune_error::{kitsune_error, ErrorType, Result};
use moka::future::Cache;
use moka::sync::Cache;

#[derive(Clone)]
pub struct InMemory {
Expand All @@ -20,12 +20,11 @@ impl Store for InMemory {
async fn get_and_remove(&self, key: &str) -> Result<LoginState> {
self.inner
.remove(key)
.await
.ok_or_else(|| kitsune_error!(type = ErrorType::BadRequest, "missing login state"))
}

async fn set(&self, key: &str, value: LoginState) -> Result<()> {
self.inner.insert(key.to_string(), value).await;
self.inner.insert(key.to_string(), value);
Ok(())
}
}
4 changes: 2 additions & 2 deletions crates/kitsune-scss-compiler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ version.workspace = true
license.workspace = true

[dependencies]
anyhow = "1.0.83"
eyre = "0.6.12"
glob = "0.3.1"
rsass = "0.28.8"
grass_compiler = "0.13.2"
tracing = { version = "0.1.40", default-features = false }

[lints]
Expand Down
11 changes: 4 additions & 7 deletions crates/kitsune-scss-compiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
use anyhow::Result;
use eyre::Result;
use glob::glob;
use rsass::output::{Format, Style};
use grass_compiler::{Options, OutputStyle};
use std::{fs, path::Path};

pub fn compile<P>(path: P) -> Result<()>
where
P: AsRef<Path>,
{
let path = path.as_ref();
let scss_format = Format {
style: Style::Compressed,
..Default::default()
};
let scss_options = Options::default().style(OutputStyle::Compressed);

let pattern = format!("{}/*.scss", path.display());
for file in glob(&pattern)? {
let mut path = file?;
tracing::info!("Compiling \"{}\" into CSS", path.display());

let compiled_css = rsass::compile_scss_path(&path, scss_format)?;
let compiled_css = grass_compiler::from_path(&path, &scss_options)?;
path.set_extension("css");
fs::write(path, compiled_css)?;
}
Expand Down
2 changes: 1 addition & 1 deletion kitsune-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ version.workspace = true
authors.workspace = true
edition.workspace = true
license.workspace = true
build = "build.rs"

[package.metadata.wix]
upgrade-guid = "566D09AC-E247-4490-B8BB-A16DB4E225DF"
Expand All @@ -20,6 +19,7 @@ diesel-async = "0.4.1"
dotenvy = "0.15.7"
envy = "0.4.2"
kitsune-config = { path = "../crates/kitsune-config" }
kitsune-core = { version = "0.0.1-pre.6", path = "../crates/kitsune-core" }
kitsune-db = { path = "../crates/kitsune-db" }
kitsune-error = { path = "../crates/kitsune-error" }
serde = { version = "1.0.201", features = ["derive"] }
Expand Down
9 changes: 0 additions & 9 deletions kitsune-cli/build.rs

This file was deleted.

3 changes: 2 additions & 1 deletion kitsune-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use self::{config::Configuration, role::RoleSubcommand};
use clap::{Parser, Subcommand};
use color_eyre::eyre::Result;
use kitsune_config::database::Configuration as DatabaseConfig;
use kitsune_core::consts::VERSION;

mod config;
mod role;
Expand All @@ -15,7 +16,7 @@ enum AppSubcommand {

/// CLI for the Kitsune social media server
#[derive(Parser)]
#[command(about, author, version = concat!(env!("CARGO_PKG_VERSION"), "-", env!("VERGEN_GIT_SHA")))]
#[command(about, author, version = VERSION)]
struct App {
#[clap(subcommand)]
subcommand: AppSubcommand,
Expand Down
5 changes: 2 additions & 3 deletions kitsune/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ oxide-auth-axum = "0.4.0"
redis = { version = "0.25.3", default-features = false, features = [
"tokio-rustls-comp",
] }
rust-embed = { version = "8.3.0", features = ["include-exclude"] }
rust-embed = { version = "8.4.0", features = ["include-exclude"] }
scoped-futures = "0.1.3"
serde = { version = "1.0.201", features = ["derive"] }
serde_urlencoded = "0.7.1"
Expand All @@ -89,7 +89,7 @@ strum = { version = "0.26.2", features = ["derive", "phf"] }
tempfile = "3.10.1"
time = "0.3.36"
tokio = { version = "1.37.0", features = ["full"] }
tokio-util = { version = "0.7.11", features = ["compat"] }
tokio-util = { version = "0.7.11", features = ["io"] }
tower = { version = "0.4.13", features = ["util"] }
tower-stop-using-brave = { path = "../lib/tower-stop-using-brave" }
tower-x-clacks-overhead = { path = "../lib/tower-x-clacks-overhead" }
Expand Down Expand Up @@ -118,7 +118,6 @@ async-graphql = { version = "7.0.5", default-features = false, features = [
"tempfile",
"time",
"tracing",
"unblock",
"uuid",
], optional = true }
async-graphql-axum = { version = "7.0.5", optional = true }
Expand Down
5 changes: 3 additions & 2 deletions kitsune/src/http/graphql/mutation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use futures_util::{Stream, TryStreamExt};
use kitsune_service::attachment;
use mime::Mime;
use std::str::FromStr;
use tokio_util::{compat::FuturesAsyncReadCompatExt, io::ReaderStream};
use tokio::fs::File;
use tokio_util::io::ReaderStream;

mod auth;
mod post;
Expand All @@ -29,7 +30,7 @@ fn handle_upload(
.or_else(|| mime_guess::from_path(&value.filename).first())
.ok_or_else(|| Error::new("Failed to determine file type"))?;

let stream = ReaderStream::new(value.into_async_read().compat()).map_err(Into::into);
let stream = ReaderStream::new(File::from_std(value.content)).map_err(Into::into);
let mut upload = attachment::Upload::builder()
.account_id(user_data.account.id)
.content_type(content_type.as_ref().into())
Expand Down
4 changes: 2 additions & 2 deletions lib/athena/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
error::{Error, Result},
JobContextRepository, JobData, JobQueue, JobResult, Outcome, Runnable,
};
use ahash::AHashMap;
use ahash::HashMap;
use futures_util::TryStreamExt;
use just_retry::RetryExt;
use speedy_uuid::Uuid;
Expand Down Expand Up @@ -40,7 +40,7 @@ where
let job_data = job_data
.into_iter()
.map(|data| (data.job_id, data))
.collect::<AHashMap<Uuid, JobData>>();
.collect::<HashMap<Uuid, JobData>>();
let job_data = Arc::new(job_data);

while let Some((job_id, job_ctx)) = context_stream
Expand Down
29 changes: 15 additions & 14 deletions lib/athena/src/redis/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use self::{scheduled::ScheduledJobActor, util::StreamAutoClaimReply};
use self::scheduled::ScheduledJobActor;
use crate::{
consts::{BLOCK_TIME, MAX_RETRIES, MIN_IDLE_TIME},
error::Result,
Expand All @@ -13,7 +13,7 @@ use just_retry::{
};
use redis::{
aio::ConnectionLike,
streams::{StreamReadOptions, StreamReadReply},
streams::{StreamAutoClaimOptions, StreamAutoClaimReply, StreamReadOptions, StreamReadReply},
AsyncCommands, RedisResult,
};
use smol_str::SmolStr;
Expand All @@ -24,7 +24,6 @@ use triomphe::Arc;
use typed_builder::TypedBuilder;

mod scheduled;
mod util;

type Pool = multiplex_pool::Pool<redis::aio::ConnectionManager>;

Expand Down Expand Up @@ -154,17 +153,19 @@ where
let mut redis_conn = self.redis_pool.get();
self.initialise_group(&mut redis_conn).await?;

let StreamAutoClaimReply { claimed_ids, .. }: StreamAutoClaimReply =
redis::cmd("XAUTOCLAIM")
.arg(self.queue_name.as_str())
.arg(self.consumer_group.as_str())
.arg(self.consumer_name.as_str())
.arg(MIN_IDLE_TIME.as_millis() as u64)
.arg("0-0")
.arg("COUNT")
.arg(max_jobs)
.query_async(&mut redis_conn)
.await?;
let StreamAutoClaimReply {
claimed: claimed_ids,
..
} = redis_conn
.xautoclaim_options(
self.queue_name.as_str(),
self.consumer_group.as_str(),
self.consumer_name.as_str(),
MIN_IDLE_TIME.as_millis() as u64,
"0-0",
StreamAutoClaimOptions::default().count(max_jobs),
)
.await?;

let claimed_ids = if claimed_ids.len() == max_jobs {
Either::Left(claimed_ids.into_iter())
Expand Down
27 changes: 0 additions & 27 deletions lib/athena/src/redis/util.rs

This file was deleted.

2 changes: 1 addition & 1 deletion lib/cursiv/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ http = "1.1.0"
pin-project-lite = "0.2.14"
rand = "0.8.5"
tower = { version = "0.4.13", default-features = false }
triomphe = "0.1.11"
zeroize = { version = "1.7.0", features = ["derive"] }

# `axum` feature
async-trait = { version = "0.1.80", optional = true }
axum-core = { version = "0.4.3", optional = true }
triomphe = "0.1.11"

[dev-dependencies]
futures-test = "0.3.30"
Expand Down
Loading
Loading