Skip to content

Commit 855572b

Browse files
authored
Merge pull request #2794 from calebschoepp/merge-kv-impls
Merge host component key value implementations into new factor crates
2 parents 8c17f33 + 1c1f8b0 commit 855572b

File tree

29 files changed

+504
-744
lines changed

29 files changed

+504
-744
lines changed

Cargo.lock

Lines changed: 16 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ spin-common = { path = "crates/common" }
4949
spin-doctor = { path = "crates/doctor" }
5050
spin-expressions = { path = "crates/expressions" }
5151
spin-http = { path = "crates/http" }
52-
spin-key-value = { path = "crates/key-value" }
53-
spin-key-value-sqlite = { path = "crates/key-value-sqlite" }
5452
spin-loader = { path = "crates/loader" }
5553
spin-locked-app = { path = "crates/locked-app" }
5654
spin-manifest = { path = "crates/manifest" }

crates/factor-key-value-azure/Cargo.toml

Lines changed: 0 additions & 19 deletions
This file was deleted.

crates/factor-key-value-azure/src/lib.rs

Lines changed: 0 additions & 58 deletions
This file was deleted.

crates/factor-key-value-redis/Cargo.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

crates/factor-key-value-redis/src/lib.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

crates/factor-key-value-spin/Cargo.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

crates/factor-key-value/Cargo.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ edition = { workspace = true }
66

77
[dependencies]
88
anyhow = "1.0"
9+
lru = "0.9.0"
910
serde = { version = "1.0", features = ["rc"] }
11+
spin-core = { path = "../core" }
1012
spin-factors = { path = "../factors" }
11-
# TODO: merge with this crate
12-
spin-key-value = { path = "../key-value" }
13+
spin-locked-app = { path = "../locked-app" }
1314
spin-world = { path = "../world" }
15+
table = { path = "../table" }
16+
tokio = { version = "1", features = ["macros", "sync", "rt"] }
1417
toml = "0.8"
18+
tracing = { workspace = true }
1519

1620
[dev-dependencies]
17-
spin-factor-key-value-redis = { path = "../factor-key-value-redis" }
18-
spin-factor-key-value-spin = { path = "../factor-key-value-spin" }
21+
spin-key-value-redis = { path = "../key-value-redis" }
22+
spin-key-value-spin = { path = "../key-value-spin" }
1923
spin-factors-test = { path = "../factors-test" }
2024
tempfile = "3.12.0"
2125
tokio = { version = "1", features = ["macros", "rt"] }

crates/key-value/src/lib.rs renamed to crates/factor-key-value/src/host.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1+
use crate::util::EmptyStoreManager;
12
use anyhow::{Context, Result};
2-
use spin_app::MetadataKey;
33
use spin_core::{async_trait, wasmtime::component::Resource};
4+
use spin_locked_app::MetadataKey;
45
use spin_world::v2::key_value;
56
use std::{collections::HashSet, sync::Arc};
67
use table::Table;
78

8-
// TODO(factors): Code left for reference; remove after migration to factors
9-
// mod host_component;
10-
mod util;
11-
12-
pub use util::{
13-
CachingStoreManager, DefaultManagerGetter, DelegatingStoreManager, EmptyStoreManager,
14-
};
15-
169
pub const KEY_VALUE_STORES_KEY: MetadataKey<Vec<String>> = MetadataKey::new("key_value_stores");
1710

1811
const DEFAULT_STORE_TABLE_CAPACITY: u32 = 256;

crates/factor-key-value/src/lib.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,32 @@
1+
mod host;
12
pub mod runtime_config;
3+
mod util;
24

35
use std::{
46
collections::{HashMap, HashSet},
57
sync::Arc,
68
};
79

810
use anyhow::ensure;
11+
use host::KEY_VALUE_STORES_KEY;
912
use spin_factors::{
1013
ConfigureAppContext, Factor, FactorInstanceBuilder, InitContext, InstanceBuilders,
1114
PrepareContext, RuntimeFactors,
1215
};
13-
use spin_key_value::{
14-
CachingStoreManager, DefaultManagerGetter, DelegatingStoreManager, KeyValueDispatch,
15-
StoreManager, KEY_VALUE_STORES_KEY,
16-
};
16+
use util::{CachingStoreManager, DefaultManagerGetter};
1717

18+
pub use host::{log_error, Error, KeyValueDispatch, Store, StoreManager};
1819
pub use runtime_config::RuntimeConfig;
20+
pub use util::DelegatingStoreManager;
1921

2022
/// A factor that provides key-value storage.
2123
pub struct KeyValueFactor {
2224
default_label_resolver: Arc<dyn DefaultLabelResolver>,
2325
}
2426

2527
impl KeyValueFactor {
26-
/// Create a new KeyValueFactor.
27-
///
28+
/// Create a new KeyValueFactor.
29+
///
2830
/// The `default_label_resolver` is used to resolve store managers for labels that
2931
/// are not defined in the runtime configuration.
3032
pub fn new(default_label_resolver: impl DefaultLabelResolver + 'static) -> Self {

0 commit comments

Comments
 (0)