Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ path = "src/lib.rs"
[dependencies]
slight-blob-store = { workspace = true, features = ["aws_s3"], optional = true }
slight-core = { workspace = true }
slight-file = { workspace = true }
slight-runtime = { workspace = true }
slight-keyvalue = { workspace = true, features = ["filesystem", "awsdynamodb", "redis", "azblob"], optional = true}
slight-distributed-locking = { workspace = true, features = ["etcd"], optional = true}
Expand Down Expand Up @@ -64,6 +65,7 @@ repository = "https://github.com/deislabs/spiderlightning"
[workspace.dependencies]
slight-blob-store = { path = "./crates/blob-store" }
slight-core = { path = "./crates/core" }
slight-file = { path = "./crates/slightfile" }
slight-runtime = { path = "./crates/runtime" }
slight-keyvalue = { path = "./crates/keyvalue" }
slight-distributed-locking = { path = "./crates/distributed-locking" }
Expand Down
1 change: 1 addition & 0 deletions crates/blob-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ repository = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
slight-file = { workspace = true }
wit-bindgen-wasmtime = { workspace = true }
wit-error-rs = { workspace = true }
slight-common = { workspace = true }
Expand Down
15 changes: 8 additions & 7 deletions crates/blob-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use async_trait::async_trait;
use container::ContainerInner;
use read_stream::ReadStreamInner;
use slight_common::{impl_resource, BasicState};
use slight_file::Resource;

use blob_store::*;
use write_stream::WriteStreamInner;
Expand All @@ -32,14 +33,14 @@ pub use implementors::azblob::AZBLOB_CAPABILITY_NAME;
/// [wasi-blob-store](https://github.com/WebAssembly/wasi-blob-store) interfaces,
#[derive(Clone, Default)]
pub struct BlobStore {
implementor: BlobStoreImplementors,
implementor: String,
capability_store: HashMap<String, BasicState>,
}

impl BlobStore {
pub fn new(implementor: String, keyvalue_store: HashMap<String, BasicState>) -> Self {
Self {
implementor: implementor.as_str().into(),
implementor,
capability_store: keyvalue_store,
}
}
Expand All @@ -56,13 +57,13 @@ pub enum BlobStoreImplementors {
None,
}

impl From<&str> for BlobStoreImplementors {
fn from(s: &str) -> Self {
impl From<Resource> for BlobStoreImplementors {
fn from(s: Resource) -> Self {
match s {
#[cfg(feature = "aws_s3")]
S3_CAPABILITY_NAME => Self::S3,
Resource::BlobstoreAwsS3 => Self::S3,
#[cfg(feature = "azblob")]
AZBLOB_CAPABILITY_NAME => Self::AzBlob,
Resource::BlobstoreAzblob => Self::AzBlob,
p => panic!(
"failed to match provided name (i.e., '{p}') to any known host implementations"
),
Expand Down Expand Up @@ -117,7 +118,7 @@ impl blob_store::BlobStore for BlobStore {
async fn container_open(&mut self, name: &str) -> Result<Self::Container, Error> {
let state = self.fetch_state(name);
tracing::log::info!("Opening implementor {}", &state.implementor);
let inner = Self::Container::new(state.implementor.as_str().into(), &state, name).await?;
let inner = Self::Container::new(state.implementor.clone().into(), &state, name).await?;

Ok(inner)
}
Expand Down
1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ doctest = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
slight-file = { workspace = true }
slight-http-api = { workspace = true }
as-any = { workspace = true }
wasmtime = { workspace = true, optional = true }
Expand Down
12 changes: 7 additions & 5 deletions crates/common/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::{
path::{Path, PathBuf},
};

use slight_file::{Resource, SecretStoreResource};

/// `BasicState` provides an attempt at a "fit-all" for basic scenarios
/// of a host's state.
///
Expand All @@ -11,19 +13,19 @@ use std::{
/// - a `name`,
/// - a `configs_map`, and
/// - the `slightfile_path`.
#[derive(Clone, Default)]
#[derive(Clone)]
pub struct BasicState {
pub secret_store: Option<String>,
pub implementor: String,
pub secret_store: Option<SecretStoreResource>,
pub implementor: Resource,
pub name: String,
pub configs_map: Option<HashMap<String, String>>,
pub slightfile_path: PathBuf,
}

impl BasicState {
pub fn new(
secret_store: Option<String>,
implementor: String,
secret_store: Option<SecretStoreResource>,
implementor: Resource,
name: String,
configs_map: Option<HashMap<String, String>>,
slightfile_path: impl AsRef<Path>,
Expand Down
2 changes: 1 addition & 1 deletion crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ doctest = false

[dependencies]
anyhow = { workspace = true }
serde = { workspace = true }
short-crypt = "1"
rand = { workspace = true }
toml = { workspace = true }
clap = { workspace = true }
semver = { workspace = true }
slight-file = { workspace = true }

[dev-dependencies]
tempdir = { workspace = true }
1 change: 0 additions & 1 deletion crates/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
pub mod interface_parser;
pub mod secret;
pub mod slightfile;
pub mod wasm_parser;
4 changes: 2 additions & 2 deletions crates/core/src/secret.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use std::{
io::Write,
};

use crate::slightfile::{Config, TomlFile};
use anyhow::{bail, Result};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use short_crypt::ShortCrypt;
use slight_file::{Config, TomlFile};

pub const SLIGHTKEY: &str = ".slightkey";

Expand Down Expand Up @@ -101,7 +101,7 @@ mod unittests {
use tempdir::TempDir;

use super::create_secret;
use crate::slightfile::TomlFile;
use slight_file::TomlFile;

#[test]
fn create_secret_test() -> Result<()> {
Expand Down
30 changes: 0 additions & 30 deletions crates/core/src/slightfile.rs

This file was deleted.

1 change: 1 addition & 0 deletions crates/distributed-locking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test = false
doctest = false

[dependencies]
slight-file = { workspace = true }
wit-bindgen-wasmtime = { workspace = true }
wit-error-rs = { workspace = true }
slight-common = { workspace = true }
Expand Down
9 changes: 5 additions & 4 deletions crates/distributed-locking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use async_trait::async_trait;

use implementors::*;
use slight_common::{impl_resource, BasicState};
use slight_file::Resource;

/// It is mandatory to `use <interface>::*` due to `impl_resource!`.
/// That is because `impl_resource!` accesses the `crate`'s
Expand Down Expand Up @@ -80,7 +81,7 @@ impl distributed_locking::DistributedLocking for DistributedLocking {

tracing::log::info!("Opening implementor {}", &state.implementor);

let inner = Self::DistributedLocking::new(state.implementor.as_str().into(), &state).await;
let inner = Self::DistributedLocking::new(state.implementor.clone().into(), &state).await;

Ok(inner)
}
Expand Down Expand Up @@ -162,11 +163,11 @@ enum DistributedLockingImplementors {
Etcd,
}

impl From<&str> for DistributedLockingImplementors {
fn from(s: &str) -> Self {
impl From<Resource> for DistributedLockingImplementors {
fn from(s: Resource) -> Self {
match s {
#[cfg(feature = "etcd")]
"distributed_locking.etcd" | "lockd.etcd" => Self::Etcd,
Resource::DistributedLockingEtcd | Resource::V1DistributedLockingEtcd => Self::Etcd,
p => panic!(
"failed to match provided name (i.e., '{p}') to any known host implementations"
),
Expand Down
5 changes: 3 additions & 2 deletions crates/keyvalue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ test = false
doctest = false

[dependencies]
wit-bindgen-wasmtime = { workspace = true }
wit-error-rs = { workspace = true }
slight-file = { workspace = true }
slight-common = { workspace = true }
slight-runtime-configs = { workspace = true }
wit-bindgen-wasmtime = { workspace = true }
wit-error-rs = { workspace = true }
anyhow = { workspace = true }
tracing = { workspace = true }
tokio = { workspace = true }
Expand Down
15 changes: 8 additions & 7 deletions crates/keyvalue/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use async_trait::async_trait;
use implementors::*;

use slight_common::{impl_resource, BasicState};
use slight_file::Resource;

/// It is mandatory to `use <interface>::*` due to `impl_resource!`.
/// That is because `impl_resource!` accesses the `crate`'s
Expand Down Expand Up @@ -107,17 +108,17 @@ pub enum KeyvalueImplementors {
Redis,
}

impl From<&str> for KeyvalueImplementors {
fn from(s: &str) -> Self {
impl From<Resource> for KeyvalueImplementors {
fn from(s: Resource) -> Self {
match s {
#[cfg(feature = "filesystem")]
"keyvalue.filesystem" | "kv.filesystem" => Self::Filesystem,
Resource::KeyvalueFilesystem | Resource::V1KeyvalueFilesystem => Self::Filesystem,
#[cfg(feature = "azblob")]
"keyvalue.azblob" | "kv.azblob" => Self::AzBlob,
Resource::KeyvalueAzblob | Resource::V1KeyvalueAzblob => Self::AzBlob,
#[cfg(feature = "awsdynamodb")]
"keyvalue.awsdynamodb" | "kv.awsdynamodb" => Self::AwsDynamoDb,
Resource::KeyvalueAwsDynamoDb | Resource::V1KeyvalueAwsDynamoDb => Self::AwsDynamoDb,
#[cfg(feature = "redis")]
"keyvalue.redis" | "kv.redis" => Self::Redis,
Resource::KeyvalueRedis | Resource::V1KeyvalueRedis => Self::Redis,
p => panic!(
"failed to match provided name (i.e., '{p}') to any known host implementations"
),
Expand Down Expand Up @@ -164,7 +165,7 @@ impl keyvalue::Keyvalue for Keyvalue {

tracing::log::info!("Opening implementor {}", &state.implementor);

let inner = Self::Keyvalue::new(state.implementor.as_str().into(), &state, name).await;
let inner = Self::Keyvalue::new(state.implementor.clone().into(), &state, name).await;

Ok(inner)
}
Expand Down
5 changes: 3 additions & 2 deletions crates/messaging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ test = false
doctest = false

[dependencies]
slight-file = { workspace = true }
slight-common = { workspace = true }
slight-runtime-configs = { workspace = true }
anyhow = { workspace = true }
wit-bindgen-wasmtime = { workspace = true }
wit-error-rs = { workspace = true }
slight-common = { workspace = true }
slight-runtime-configs = { workspace = true }
uuid = { version = "1.1", features = ["v4"] }
tracing = { workspace = true }
crossbeam-channel = "0.5"
Expand Down
Loading