Skip to content

Commit

Permalink
Cloud next (#173)
Browse files Browse the repository at this point in the history
* Client API changes to accomodate new cloud architecture

The exact trait interfaces for `client-api` is TBD

* Ensure we're not blocking when accessing the filesystem

* Derive Clone for SendGridController

* Add YOLO error variant to InsertDomainResult

* Rebase

* fixup! Rebase

* Fix SpacetimeType for Address

* Temporarily disable message / frame size limits for SDK WS

* Remove get_database_instance_state from API trait

It's an internal (worker db) thing, which does not need to be satisfied
by impls.

* Update indexes when updating a database

It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.

* Update indexes when updating a database

It turns out that the order of the index definitions in the proposed
schema may differ from those returned from the catalog, causing valid
(i.e. no-op) updates to be rejected. While at it, allow updating table
indexes so as long as the (column) schema remains unchanged.

* Fix -S instead of -s for update-module smoke test

-s now means "server", -S "skip clippy", changed in:

a1e9984 (Multiple server configurations for CLI (#214), 2023-09-01)

* Invalidate schema cache when committing a tx

* Use long options in update-module.sh, fix unused warning

* Add test asserting schema_for_table reflects index updates
  • Loading branch information
kim authored Sep 20, 2023
1 parent 3d4e384 commit ea2bae4
Show file tree
Hide file tree
Showing 26 changed files with 1,080 additions and 731 deletions.
9 changes: 8 additions & 1 deletion crates/bindings/src/impls.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use spacetimedb_lib::{DataKey, Hash, Identity};
use spacetimedb_lib::{Address, DataKey, Hash, Identity};

use super::PrimaryKey;
use crate::{FilterableValue, UniqueValue};
Expand Down Expand Up @@ -54,3 +54,10 @@ impl UniqueValue for Identity {
todo!() // idk what this is
}
}

impl FilterableValue for Address {}
impl UniqueValue for Address {
fn into_primarykey(self) -> PrimaryKey {
todo!()
}
}
2 changes: 2 additions & 0 deletions crates/cli/src/subcommands/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub async fn exec_set_name(mut config: Config, args: &ArgMatches) -> Result<(),

let res = builder.send().await?.error_for_status()?;
let bytes = res.bytes().await.unwrap();
println!("{}", String::from_utf8_lossy(&bytes[..]));
let result: InsertDomainResult = serde_json::from_slice(&bytes[..]).unwrap();
match result {
InsertDomainResult::Success { domain, address } => {
Expand Down Expand Up @@ -212,6 +213,7 @@ pub async fn exec_set_name(mut config: Config, args: &ArgMatches) -> Result<(),
)),
};
}
InsertDomainResult::OtherError(e) => return Err(anyhow::anyhow!(e)),
}

Ok(())
Expand Down
10 changes: 5 additions & 5 deletions crates/client-api/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use spacetimedb::auth::identity::{
use spacetimedb::host::EnergyDiff;
use spacetimedb::identity::Identity;

use crate::{log_and_500, ControlNodeDelegate};
use crate::{log_and_500, ControlStateDelegate, NodeDelegate};

// Yes, this is using basic auth. See the below issues.
// The current form is: Authorization: Basic base64("token:<token>")
Expand Down Expand Up @@ -75,7 +75,7 @@ pub struct TokenQueryParam {
}

#[async_trait::async_trait]
impl<S: ControlNodeDelegate + Send + Sync> axum::extract::FromRequestParts<S> for SpacetimeAuthHeader {
impl<S: NodeDelegate + Send + Sync> axum::extract::FromRequestParts<S> for SpacetimeAuthHeader {
type Rejection = AuthorizationRejection;
async fn from_request_parts(parts: &mut request::Parts, state: &S) -> Result<Self, Self::Rejection> {
match (
Expand Down Expand Up @@ -168,8 +168,8 @@ enum AuthorizationRejectionReason {
}

impl SpacetimeAuth {
pub async fn alloc(ctx: &(impl ControlNodeDelegate + ?Sized)) -> axum::response::Result<Self> {
let identity = ctx.alloc_spacetime_identity().await.map_err(log_and_500)?;
pub async fn alloc(ctx: &(impl NodeDelegate + ControlStateDelegate + ?Sized)) -> axum::response::Result<Self> {
let identity = ctx.create_identity().await.map_err(log_and_500)?;
let creds = SpacetimeCreds::encode_token(ctx.private_key(), identity).map_err(log_and_500)?;
Ok(Self { creds, identity })
}
Expand All @@ -192,7 +192,7 @@ impl SpacetimeAuthHeader {
/// If there is no JWT in the auth header we will create a new identity and token and return it.
pub async fn get_or_create(
self,
ctx: &(impl ControlNodeDelegate + ?Sized),
ctx: &(impl NodeDelegate + ControlStateDelegate + ?Sized),
) -> axum::response::Result<SpacetimeAuth> {
match self.get() {
Some(auth) => Ok(auth),
Expand Down
Loading

0 comments on commit ea2bae4

Please sign in to comment.