Move websocket code into workspace #107

Merged
dessalines merged 7 commits from move-websocket-to-workspace into main 2020-09-24 13:53:23 +00:00
Owner

Need to clean this up and then actually move websocket into its own workspace

Need to clean this up and then actually move websocket into its own workspace
Author
Owner

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.

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.
Author
Owner

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).

on main: 3m 45s, 3m 58s, 4m 02s
after moving websocket to workspace: 3m 29s, 4m 22s, 3m 55s
after moving api, apub to workspaces: 4m 09s, 3m 35s, 3m 43s
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). ``` on main: 3m 45s, 3m 58s, 4m 02s after moving websocket to workspace: 3m 29s, 4m 22s, 3m 55s after moving api, apub to workspaces: 4m 09s, 3m 35s, 3m 43s ```
Owner

Going through this now, but just a note that it failed on travis here: https://travis-ci.org/github/LemmyNet/lemmy/builds/729704932#L351

Going through this now, but just a note that it failed on travis here: https://travis-ci.org/github/LemmyNet/lemmy/builds/729704932#L351
dessalines reviewed 2020-09-23 20:49:47 +00:00
dessalines left a comment
Owner

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.

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>> + '_>>;
Owner

This is really weird to me. Why does a function need to be a type. Why not just call the function.

This is really weird to me. Why does a function need to be a type. Why not just call the function.
Author
Owner

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.

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,
Owner

Why pass in a function here?

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);
Owner

Same, this could just call the function instead of referring to the type.

Same, this could just call the function instead of referring to the type.
Author
Owner

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).

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).
Owner

Mmmk everything passed, so I'll merge.

Mmmk everything passed, so I'll merge.
dessalines merged commit 442369a041 into main 2020-09-24 13:53:22 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: LemmyNet/lemmy#107
No description provided.