diff --git a/Cargo.lock b/Cargo.lock index 781b639d7..95d57cf3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -494,7 +494,6 @@ dependencies = [ "actix-test", "actix-web", "actix-ws", - "autoconnect_registry", "autoconnect_settings", "autoconnect_web", "autoconnect_ws", @@ -530,13 +529,15 @@ dependencies = [ ] [[package]] -name = "autoconnect_registry" +name = "autoconnect_common" version = "1.66.0" dependencies = [ - "autoconnect_ws", "autopush_common", - "futures 0.3.27", "futures-locks 0.7.1", + "reqwest 0.11.15", + "serde", + "serde_derive", + "serde_json", "slog", "slog-scope", "uuid 1.3.0", @@ -546,7 +547,7 @@ dependencies = [ name = "autoconnect_settings" version = "1.66.0" dependencies = [ - "autoconnect_registry", + "autoconnect_common", "autopush_common", "cadence", "config", @@ -567,7 +568,7 @@ dependencies = [ "actix-rt", "actix-web", "actix-ws", - "autoconnect_registry", + "autoconnect_common", "autoconnect_settings", "autoconnect_ws", "autopush_common", @@ -599,7 +600,6 @@ name = "autoconnect_ws_clientsm" version = "1.66.0" dependencies = [ "actix-web", - "autoconnect_registry", "autoconnect_settings", "autoconnect_web", "autoconnect_ws", diff --git a/Cargo.toml b/Cargo.toml index 2f2c65277..4442a18a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ members = [ "autopush", "autoendpoint", "autoconnect", + "autoconnect/autoconnect-common", "autoconnect/autoconnect-settings", "autoconnect/autoconnect-web", "autoconnect/autoconnect-ws", @@ -87,13 +88,13 @@ tungstenite = { version = "0.9.2", default-features = false } # 0.10+ requires uuid = { version = "1.1", features = ["serde", "v4"] } url = "2.2" -autoconnect = {path = "./autoconnect"} -autopush_common = {path = "./autopush-common"} -autoconnect_registry = {path = "./autoconnect/autoconnect-registry"} -autoconnect_settings = {path = "./autoconnect/autoconnect-settings"} -autoconnect_web = {path = "./autoconnect/autoconnect-web"} -autoconnect_ws = {path = "./autoconnect/autoconnect-ws"} -autoconnect_ws_clientsm = {path ="./autoconnect/autoconnect-ws/autoconnect-ws-clientsm"} +autoconnect = { path = "./autoconnect" } +autoconnect_common = { path = "./autoconnect/autoconnect-common" } +autoconnect_settings = { path = "./autoconnect/autoconnect-settings" } +autoconnect_web = { path = "./autoconnect/autoconnect-web" } +autoconnect_ws = { path = "./autoconnect/autoconnect-ws" } +autoconnect_ws_clientsm = { path ="./autoconnect/autoconnect-ws/autoconnect-ws-clientsm" } +autopush_common = { path = "./autopush-common" } [profile.release] debug = 1 diff --git a/autoconnect/Cargo.toml b/autoconnect/Cargo.toml index fcae21725..14cc9e537 100644 --- a/autoconnect/Cargo.toml +++ b/autoconnect/Cargo.toml @@ -41,7 +41,6 @@ slog-stdlog.workspace = true slog-term.workspace = true uuid.workspace = true -autoconnect_registry.workspace = true autoconnect_settings.workspace = true autoconnect_web.workspace = true autoconnect_ws.workspace = true diff --git a/autoconnect/autoconnect-registry/Cargo.toml b/autoconnect/autoconnect-common/Cargo.toml similarity index 50% rename from autoconnect/autoconnect-registry/Cargo.toml rename to autoconnect/autoconnect-common/Cargo.toml index 03b048f70..2b9e51157 100644 --- a/autoconnect/autoconnect-registry/Cargo.toml +++ b/autoconnect/autoconnect-common/Cargo.toml @@ -1,16 +1,20 @@ [package] -name = "autoconnect_registry" -version.workspace = true +name = "autoconnect_common" authors.workspace = true edition.workspace = true +version.workspace = true +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -futures.workspace = true futures-locks.workspace = true +reqwest.workspace = true +serde.workspace = true +serde_derive.workspace = true +serde_json.workspace = true slog.workspace = true slog-scope.workspace = true uuid.workspace = true -autoconnect_ws.workspace = true + autopush_common.workspace = true diff --git a/autoconnect/autoconnect-web/src/broadcast.rs b/autoconnect/autoconnect-common/src/broadcast.rs similarity index 100% rename from autoconnect/autoconnect-web/src/broadcast.rs rename to autoconnect/autoconnect-common/src/broadcast.rs diff --git a/autoconnect/autoconnect-common/src/lib.rs b/autoconnect/autoconnect-common/src/lib.rs new file mode 100644 index 000000000..34a1559f0 --- /dev/null +++ b/autoconnect/autoconnect-common/src/lib.rs @@ -0,0 +1,6 @@ +#[macro_use] +extern crate slog_scope; + +pub mod broadcast; +pub mod protocol; +pub mod registry; diff --git a/autoconnect/autoconnect-web/src/protocol.rs b/autoconnect/autoconnect-common/src/protocol.rs similarity index 100% rename from autoconnect/autoconnect-web/src/protocol.rs rename to autoconnect/autoconnect-common/src/protocol.rs diff --git a/autoconnect/autoconnect-registry/src/lib.rs b/autoconnect/autoconnect-common/src/registry.rs similarity index 97% rename from autoconnect/autoconnect-registry/src/lib.rs rename to autoconnect/autoconnect-common/src/registry.rs index d0a3df366..c4c58ab51 100644 --- a/autoconnect/autoconnect-registry/src/lib.rs +++ b/autoconnect/autoconnect-common/src/registry.rs @@ -1,7 +1,3 @@ -// move to own crate to avoid cyclic crate errors. -#[macro_use] -extern crate slog_scope; - use std::collections::HashMap; use futures_locks::RwLock; diff --git a/autoconnect/autoconnect-settings/Cargo.toml b/autoconnect/autoconnect-settings/Cargo.toml index cc20eb596..08ba80e7a 100644 --- a/autoconnect/autoconnect-settings/Cargo.toml +++ b/autoconnect/autoconnect-settings/Cargo.toml @@ -15,5 +15,5 @@ serde_derive.workspace = true slog.workspace = true slog-scope.workspace = true +autoconnect_common.workspace = true autopush_common.workspace = true -autoconnect_registry.workspace = true diff --git a/autoconnect/autoconnect-settings/src/options.rs b/autoconnect/autoconnect-settings/src/options.rs index c4e1dec5c..55ef3daf5 100644 --- a/autoconnect/autoconnect-settings/src/options.rs +++ b/autoconnect/autoconnect-settings/src/options.rs @@ -6,7 +6,7 @@ use cadence::StatsdClient; use fernet::{Fernet, MultiFernet}; use crate::{Settings, ENV_PREFIX}; -use autoconnect_registry::ClientRegistry; +use autoconnect_common::registry::ClientRegistry; use autopush_common::db::{client::DbClient, dynamodb::DdbClientImpl, DbSettings, StorageType}; use autopush_common::{ errors::{ApcErrorKind, Result}, diff --git a/autoconnect/autoconnect-web/Cargo.toml b/autoconnect/autoconnect-web/Cargo.toml index dff1ed359..d35ffd68d 100644 --- a/autoconnect/autoconnect-web/Cargo.toml +++ b/autoconnect/autoconnect-web/Cargo.toml @@ -25,7 +25,7 @@ slog-scope.workspace = true uuid.workspace = true -autoconnect_registry.workspace = true +autoconnect_common.workspace = true autoconnect_settings.workspace = true autoconnect_ws.workspace = true autopush_common.workspace = true diff --git a/autoconnect/autoconnect-web/src/client.rs b/autoconnect/autoconnect-web/src/client.rs index b21bf6a53..c06061426 100644 --- a/autoconnect/autoconnect-web/src/client.rs +++ b/autoconnect/autoconnect-web/src/client.rs @@ -11,16 +11,17 @@ use futures_util::StreamExt; use serde_json::json; use uuid::Uuid; -use autoconnect_registry::RegisteredClient; +use autoconnect_common::{ + broadcast::Broadcast, + protocol::{ClientAck, ClientMessage, ServerMessage}, + registry::RegisteredClient, +}; use autoconnect_settings::options::AppState; use autopush_common::db::{self, User}; use autopush_common::errors::{ApcError, ApcErrorKind, Result}; use autopush_common::notification::Notification; use autopush_common::util::ms_since_epoch; -use crate::broadcast::Broadcast; -use crate::protocol::{ClientAck, ClientMessage, ServerMessage}; - /// Client & Registry functions. /// These are common functions run by connected WebSocket clients. /// These are called from the Autoconnect server. diff --git a/autoconnect/autoconnect-web/src/lib.rs b/autoconnect/autoconnect-web/src/lib.rs index c3550228e..164e465b3 100644 --- a/autoconnect/autoconnect-web/src/lib.rs +++ b/autoconnect/autoconnect-web/src/lib.rs @@ -6,8 +6,6 @@ extern crate slog; #[macro_use] extern crate slog_scope; -pub mod broadcast; pub mod client; pub mod dockerflow; pub mod metrics; -pub mod protocol; diff --git a/autoconnect/autoconnect-ws/autoconnect-ws-clientsm/Cargo.toml b/autoconnect/autoconnect-ws/autoconnect-ws-clientsm/Cargo.toml index 31904df6f..46584a185 100644 --- a/autoconnect/autoconnect-ws/autoconnect-ws-clientsm/Cargo.toml +++ b/autoconnect/autoconnect-ws/autoconnect-ws-clientsm/Cargo.toml @@ -11,7 +11,6 @@ actix-web.workspace = true uuid.workspace = true autopush_common.workspace = true -autoconnect_registry.workspace = true autoconnect_settings.workspace = true autoconnect_web.workspace = true autoconnect_ws.workspace = true