Page MenuHomePhabricator

[backup] Basic http server
ClosedPublic

Authored by michal on Aug 21 2023, 2:13 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 4, 1:40 PM
Unknown Object (File)
Thu, Apr 4, 1:40 PM
Unknown Object (File)
Thu, Apr 4, 1:40 PM
Unknown Object (File)
Thu, Apr 4, 1:40 PM
Unknown Object (File)
Thu, Apr 4, 1:39 PM
Unknown Object (File)
Thu, Apr 4, 1:28 PM
Unknown Object (File)
Feb 23 2024, 5:08 AM
Unknown Object (File)
Feb 19 2024, 7:02 AM
Subscribers

Details

Summary

ENG-4501

Backup will be now an http server so adding basic http server.

Depends on D8881

Test Plan

cargo run, navigate to localhost:51002/hello and check if it returns world

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

services/backup/src/constants.rs
34 ↗(On Diff #30128)

Taken blob's http port + 1 as http port.

services/backup/src/database.rs
110–116 ↗(On Diff #30128)

actix::web::Data has Arc inside it so we don't need another layer of indirection here

services/backup/Cargo.toml
17–26 ↗(On Diff #30154)

Not sure what others think, but now that comm-services-lib has a notion of actix, we may want to just re-export actix-web from comm-service-lib to avoid issues where differences in versions may be mutually incompatible. This does have the effect that bumping actix in comm-services-lib will need to handle version bumps across all down-stream crates.

e.g.

// comm-services-lib/src/lib.rs
#[cfg(feature = "http")]
pub mod http;
#[cfg(feature = "http")]
pub use actix-web

calling code:

use comm_services_lib::actix_web::{web, App, HttpServer};
services/backup/Cargo.toml
17–26 ↗(On Diff #30154)

Yeah I think this is a great idea! This would also solve aws-sdk-* inconsistencies if we had a crate feature database in lib and used its re-exports as a single source of truth for AWS SDKs.

But we'd need to sync about our services - me and @michal are doing lots of related stuff concurrently. I'd schedule this as a follow up right after we land our services.

services/backup/Cargo.toml
17–26 ↗(On Diff #30154)

Makes sense to me! If we decide to use cargo workspaces there's a builtin feature ("sharing dependencies") that would have a similar effect:

# [PROJECT_DIR]/Cargo.toml
[workspace]
members = ["bar"]

[workspace.dependencies]
rand = "0.8.5"
[package]
name = "bar"
version = "0.2.0"

[dependencies]
rand.workspace = true
services/backup/Cargo.toml
17–26 ↗(On Diff #30154)

That's impressive! Wondering about how to make rand.workspace = true optional and enabled only for a specific feature:

[dependencies]
rand.workspace = { optional = true }

[features]
some_feature = [ "dep:rand"]
services/backup/Cargo.toml
17–26 ↗(On Diff #30154)

You can do something like this:

[features]
f_anyhow = ["dep:anyhow"]

[dependencies]
anyhow = { workspace = true, optional = true }

Although I still think we should move to separate crates instead of features. Even with only two features in comm-services-lib (blob-client and http), it's cargo.toml is getting a little unwieldy 😅 (on the other hand, no orphan rules to worry about is nice).

This revision is now accepted and ready to land.Aug 22 2023, 3:49 AM

Update http port to the previous gRPC port, similar to the planned blob service changes