-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
325 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,13 @@ | ||
pub mod providers; | ||
|
||
#[cfg(any( | ||
all(feature = "cloudflare", feature = "native"), | ||
all(feature = "cloudflare", feature = "wasi"), | ||
all(feature = "native", feature = "wasi") | ||
))] | ||
compile_error!( | ||
"Only one of the `cloudflare`, `native`, or `wasi` features can be enabled at a time." | ||
); | ||
|
||
#[cfg(not(any(feature = "cloudflare", feature = "native", feature = "wasi")))] | ||
compile_error!("At least one of the `cloudflare`, `native`, or `wasi` features must be enabled."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::sync::Arc; | ||
|
||
use worker::Env; | ||
|
||
use super::KVStore; | ||
|
||
pub struct ProxyKV { | ||
env: Arc<Env>, | ||
db_name: String, | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl KVStore for ProxyKV { | ||
async fn set(&self, key: impl ToString, value: impl ToString) { | ||
todo!() | ||
} | ||
|
||
async fn get(&self, key: impl ToString) -> Option<String> { | ||
todo!() | ||
} | ||
|
||
async fn delete(&self, key: impl ToString) { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#[cfg(feature = "cloudflare")] | ||
pub mod cloudflare; | ||
#[cfg(feature = "native")] | ||
pub mod sled; | ||
#[cfg(feature = "wasi")] | ||
pub mod wasmtime_wasi; | ||
|
||
#[cfg(feature = "cloudflare")] | ||
pub use cloudflare::*; | ||
#[cfg(feature = "native")] | ||
pub use sled::*; | ||
#[cfg(feature = "wasi")] | ||
pub use wasmtime_wasi::*; | ||
|
||
pub trait KVStore { | ||
async fn get(&self, key: impl ToString) -> Option<String>; | ||
async fn set(&self, key: impl ToString, value: impl ToString); | ||
async fn delete(&self, key: impl ToString); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use super::KVStore; | ||
|
||
pub struct ProxyKV { | ||
path: String, | ||
} | ||
|
||
#[async_trait::async_trait] | ||
impl KVStore for ProxyKV { | ||
async fn set(&self, key: impl ToString, value: impl ToString) { | ||
todo!() | ||
} | ||
|
||
async fn get(&self, key: impl ToString) -> Option<String> { | ||
todo!() | ||
} | ||
|
||
async fn delete(&self, key: impl ToString) { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use super::KVStore; | ||
|
||
pub struct ProxyKV {} | ||
|
||
#[async_trait::async_trait] | ||
impl KVStore for ProxyKV { | ||
async fn set(&self, key: impl ToString, value: impl ToString) { | ||
todo!() | ||
} | ||
|
||
async fn get(&self, key: impl ToString) -> Option<String> { | ||
todo!() | ||
} | ||
|
||
async fn delete(&self, key: impl ToString) { | ||
todo!() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#[cfg(feature = "cloudflare")] | ||
pub mod cloudflare; | ||
pub mod kv; | ||
pub mod sql; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
use anyhow::{Context, Result}; | ||
|
||
use sea_orm::{ConnectOptions, Database, DatabaseConnection}; | ||
|
||
pub async fn init_db(path: impl ToString) -> Result<DatabaseConnection> { | ||
let options = ConnectOptions::new(format!("sqlite:{}", path.to_string())); | ||
|
||
let db = Database::connect(options) | ||
.await | ||
.context("Failed to connect to database")?; | ||
|
||
Ok(db) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[cfg(feature = "cloudflare")] | ||
pub mod cloudflare; | ||
#[cfg(feature = "native")] | ||
pub mod libsqlite; | ||
#[cfg(feature = "wasi")] | ||
pub mod wasmtime_wasi; | ||
|
||
#[cfg(feature = "cloudflare")] | ||
pub use cloudflare::*; | ||
#[cfg(feature = "native")] | ||
pub use libsqlite::*; | ||
#[cfg(feature = "wasi")] | ||
pub use wasmtime_wasi::*; |
Oops, something went wrong.