Move websocket code into workspace #107
Loading…
Reference in New Issue
No description provided.
Delete Branch "move-websocket-to-workspace"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Need to clean this up and then actually move websocket into its own workspace
Got it, websocket, api and apub are all in separate workspaces now! It might not benefit compile times much, because the workspaces depend on each other linearly and dont allow for parallel compilation.
I used cargo-udeps to get rid of unused dependencies, but it doesnt seem to work on the main project. So we might have to try manually which deps can be removed.
For lemmy_api we should split up lib.rs, and probably move the stuff there into an
internals
folder.Here are some measurements for compilation time, done with
cargo clean && RUSTC_WRAPPER= cargo +nightly build -Ztimings
. There is a lot of variance, but it looks like compilation time has not improved from this (as expected).Going through this now, but just a note that it failed on travis here: https://travis-ci.org/github/LemmyNet/lemmy/builds/729704932#L351
Its kinda tough to go through this one because most of it is just a re-org, but unfortunately its blocks of code, not files, so git isn't smart enough to do simple moved files.
But once the tests pass on travis, I'll test on the federation test instances too, since travis doesn't do websocket testing.
@ -0,0 +33,4 @@
id: ConnectionId,
op: UserOperation,
data: &str,
) -> Pin<Box<dyn Future<Output = Result<String, LemmyError>> + '_>>;
This is really weird to me. Why does a function need to be a type. Why not just call the function.
This was the only option I found to remove the dependency of websocket on api. If I left it as a normal function call, then websocket would depend on api, while api also depends on websocket. So it would be impossible to move them into separate crates.
@ -0,0 +82,4 @@
pub fn startup(
pool: Pool<ConnectionManager<PgConnection>>,
rate_limiter: RateLimit,
message_handler: MessageHandlerType,
Why pass in a function here?
@ -0,0 +371,4 @@
})?;
let user_operation = UserOperation::from_str(&op)?;
let fut = (message_handler)(context, msg.id, user_operation.clone(), data);
Same, this could just call the function instead of referring to the type.
Just pushed a commit to fix the Docker builds (and Travis). I also removed unused dependencies in the main project (where the code that used it was moved into workspaces).
Mmmk everything passed, so I'll merge.