Skip to content

Commit

Permalink
Merge contracts and common crates (#105)
Browse files Browse the repository at this point in the history
Merge contracts and common crates to simplify directory structure. This also helps deal with a circular dependency that arose in finishing #18
  • Loading branch information
wilyle authored Jan 9, 2024
1 parent 8844d4b commit 6f4547b
Show file tree
Hide file tree
Showing 56 changed files with 64 additions and 116 deletions.
31 changes: 5 additions & 26 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ members = [
"build_common",
"cloud_adapters/in_memory_mock_cloud_adapter",
"common",
"contracts",
"digital_twin_adapters/in_memory_mock_digital_twin_adapter",
"digital_twin_adapters/mock_digital_twin_adapter",
"freyja",
Expand Down
2 changes: 1 addition & 1 deletion cloud_adapters/in_memory_mock_cloud_adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ license = "MIT"

[dependencies]
async-trait = { workspace = true }
freyja-contracts = { workspace = true }
freyja-common = { workspace = true }
log = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use async_trait::async_trait;
use log::{debug, info};

use freyja_contracts::cloud_adapter::{
use freyja_common::cloud_adapter::{
CloudAdapter, CloudAdapterError, CloudMessageRequest, CloudMessageResponse,
};

Expand Down
5 changes: 4 additions & 1 deletion common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ edition = "2021"
license = "MIT"

[dependencies]
async-trait = { workspace = true }
config = { workspace = true }
freyja-contracts = { workspace = true }
crossbeam = { workspace = true }
home = { workspace = true }
log = { workspace = true }
proc-macros = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
strum = { workspace = true }
strum_macros = { workspace = true }
tokio = { workspace = true }
File renamed without changes.
4 changes: 2 additions & 2 deletions contracts/src/conversion.rs → common/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl Conversion {
///
/// # Example
/// ```rust
/// use freyja_contracts::conversion::Conversion;
/// use freyja_common::conversion::Conversion;
/// let c2f = Conversion::c_to_f();
/// assert!(42.0 == c2f.inverse().apply(c2f.apply(42.0)));
/// ```
Expand All @@ -56,7 +56,7 @@ impl Conversion {
///
/// # Example
/// ```rust
/// use freyja_contracts::conversion::Conversion;
/// use freyja_common::conversion::Conversion;
/// let c2f = Conversion::c_to_f();
/// assert!(32.0 == c2f.apply(0.0));
/// assert!(212.0 == c2f.apply(100.0));
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 9 additions & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@
// Licensed under the MIT license.
// SPDX-License-Identifier: MIT

pub mod cloud_adapter;
pub mod cmd_utils;
pub mod config_utils;
pub mod conversion;
pub mod digital_twin_adapter;
pub mod digital_twin_map_entry;
pub mod entity;
pub mod mapping_client;
pub mod message_utils;
pub mod provider_proxy;
pub mod provider_proxy_selector;
pub mod retry_utils;
pub mod signal;
pub mod signal_store;

/// Expands to `env!("OUT_DIR")`.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions common/src/signal_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use std::{collections::HashMap, sync::RwLock};

use freyja_contracts::signal::{Emission, Signal, SignalPatch};
use crate::signal::{Emission, Signal, SignalPatch};

/// Stores signals and allows access in a thread-safe manner with support for multiple concurrent readers.
/// Suitable for use as `Arc<SignalStore>`.
Expand Down Expand Up @@ -214,7 +214,7 @@ mod signal_store_tests {

use std::collections::HashSet;

use freyja_contracts::{
use crate::{
conversion::Conversion,
entity::{Entity, EntityEndpoint},
signal::{Emission, EmissionPolicy, Target},
Expand Down
17 changes: 0 additions & 17 deletions contracts/Cargo.toml

This file was deleted.

13 changes: 0 additions & 13 deletions contracts/src/lib.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ license = "MIT"
async-trait = { workspace = true }
freyja-build-common = { workspace = true }
freyja-common = { workspace = true }
freyja-contracts = { workspace = true }
serde = { workspace = true }
tokio = { workspace = true }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use serde::{Deserialize, Serialize};

use freyja_contracts::entity::Entity;
use freyja_common::entity::Entity;

/// The in-memory mock digital twin's config
#[derive(Clone, Debug, Serialize, Deserialize)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ use async_trait::async_trait;

use crate::config::Config;
use freyja_build_common::config_file_stem;
use freyja_common::{config_utils, out_dir};
use freyja_contracts::digital_twin_adapter::{
use freyja_common::digital_twin_adapter::{
DigitalTwinAdapter, DigitalTwinAdapterError, DigitalTwinAdapterErrorKind, FindByIdRequest,
FindByIdResponse,
};
use freyja_common::{config_utils, out_dir};

/// In-memory mock that mocks finding endpoint info about entities
/// through find by id
Expand Down Expand Up @@ -68,7 +68,7 @@ mod in_memory_mock_digital_twin_adapter_tests {
use super::*;

use crate::config::EntityConfig;
use freyja_contracts::entity::{Entity, EntityEndpoint};
use freyja_common::entity::{Entity, EntityEndpoint};

const OPERATION: &str = "Subscribe";

Expand Down
1 change: 0 additions & 1 deletion digital_twin_adapters/mock_digital_twin_adapter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ license = "MIT"
async-trait = { workspace = true }
freyja-build-common = { workspace = true }
freyja-common = { workspace = true }
freyja-contracts = { workspace = true }
mock-digital-twin = { workspace = true }
reqwest = { workspace = true }
serde = { workspace = true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ use reqwest::Client;

use crate::config::Config;
use freyja_build_common::config_file_stem;
use freyja_common::{config_utils, out_dir};
use freyja_contracts::digital_twin_adapter::{
use freyja_common::digital_twin_adapter::{
DigitalTwinAdapter, DigitalTwinAdapterError, FindByIdRequest, FindByIdResponse,
};
use freyja_common::{config_utils, out_dir};
use mock_digital_twin::ENTITY_QUERY_PATH;

/// Mocks a Digital Twin Adapter that calls the mocks/mock_digital_twin
Expand Down
1 change: 0 additions & 1 deletion freyja/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ license = "MIT"
[dependencies]
crossbeam = { workspace = true }
env_logger = { workspace = true }
freyja-contracts = { workspace = true }
freyja-common = { workspace = true }
log = { workspace = true }
proc-macros = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions freyja/src/cartographer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio::sync::Mutex;
use log::{debug, info, warn};

use freyja_common::signal_store::SignalStore;
use freyja_contracts::{
use freyja_common::{
conversion::Conversion,
digital_twin_adapter::{
DigitalTwinAdapter, DigitalTwinAdapterError, DigitalTwinAdapterErrorKind, FindByIdRequest,
Expand Down Expand Up @@ -231,7 +231,7 @@ mod cartographer_tests {
use async_trait::async_trait;
use mockall::{predicate::eq, *};

use freyja_contracts::{
use freyja_common::{
digital_twin_adapter::{DigitalTwinAdapterError, FindByIdResponse},
digital_twin_map_entry::DigitalTwinMapEntry,
entity::{Entity, EntityEndpoint},
Expand Down
4 changes: 2 additions & 2 deletions freyja/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use time::OffsetDateTime;
use tokio::{sync::Mutex, time::sleep};

use freyja_common::signal_store::SignalStore;
use freyja_contracts::{
use freyja_common::{
cloud_adapter::{CloudAdapter, CloudMessageRequest, CloudMessageResponse},
provider_proxy::SignalValue,
provider_proxy_selector::ProviderProxySelector,
Expand Down Expand Up @@ -227,7 +227,7 @@ mod emitter_tests {

use async_trait::async_trait;

use freyja_contracts::{
use freyja_common::{
cloud_adapter::{CloudAdapterError, CloudAdapterErrorKind},
entity::Entity,
provider_proxy::ProviderProxyFactory,
Expand Down
8 changes: 4 additions & 4 deletions freyja/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ use tokio::sync::Mutex;
use cartographer::Cartographer;
use emitter::Emitter;
use freyja_common::{
cmd_utils::{get_log_level, parse_args},
signal_store::SignalStore,
};
use freyja_contracts::{
cloud_adapter::CloudAdapter, digital_twin_adapter::DigitalTwinAdapter,
mapping_client::MappingClient, provider_proxy::SignalValue,
provider_proxy_selector::ProviderProxySelector,
};
use freyja_common::{
cmd_utils::{get_log_level, parse_args},
signal_store::SignalStore,
};
use provider_proxy_selector::provider_proxy_selector_impl::ProviderProxySelectorImpl;

use grpc_provider_proxy_v1::grpc_provider_proxy_factory::GRPCProviderProxyFactory;
Expand Down
Loading

0 comments on commit 6f4547b

Please sign in to comment.