Skip to content

Commit

Permalink
refactor: move broadcast/protocol/registry into a common crate (#357)
Browse files Browse the repository at this point in the history
as they need to be used by multiple autoconnect crates

Issue: SYNC-3581
  • Loading branch information
pjenvey authored Mar 30, 2023
1 parent 7e5151a commit fa9109d
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 33 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"autopush",
"autoendpoint",
"autoconnect",
"autoconnect/autoconnect-common",
"autoconnect/autoconnect-settings",
"autoconnect/autoconnect-web",
"autoconnect/autoconnect-ws",
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion autoconnect/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions autoconnect/autoconnect-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[macro_use]
extern crate slog_scope;

pub mod broadcast;
pub mod protocol;
pub mod registry;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion autoconnect/autoconnect-settings/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion autoconnect/autoconnect-settings/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
2 changes: 1 addition & 1 deletion autoconnect/autoconnect-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions autoconnect/autoconnect-web/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions autoconnect/autoconnect-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fa9109d

Please sign in to comment.