Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 0 additions & 2 deletions crates/bindings-cpp/include/spacetimedb/abi/FFI.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,9 @@ using ::identity;
using ::get_jwt;

// ===== Procedure Transactions =====
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
using ::procedure_start_mut_tx;
using ::procedure_commit_mut_tx;
using ::procedure_abort_mut_tx;
#endif

// ===== Module Export Helpers =====

Expand Down
2 changes: 0 additions & 2 deletions crates/bindings-cpp/include/spacetimedb/abi/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ STDB_IMPORT_10_2(get_jwt)
Status get_jwt(const uint8_t* connection_id_ptr, BytesSource* out);

// ===== Procedure Transactions (spacetime_10.3) =====
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
STDB_IMPORT_10_3(procedure_start_mut_tx)
Status procedure_start_mut_tx(int64_t* out);

Expand All @@ -190,7 +189,6 @@ Status procedure_http_request(
const uint8_t* request_ptr, size_t request_len,
const uint8_t* body_ptr, size_t body_len,
BytesSource out[2]);
#endif

} // extern "C"

Expand Down
10 changes: 1 addition & 9 deletions crates/bindings-cpp/include/spacetimedb/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@

#pragma once

#ifndef SPACETIMEDB_UNSTABLE_FEATURES
#error "spacetimedb/http.h requires SPACETIMEDB_UNSTABLE_FEATURES to be enabled"
#endif

#include <string>
#include <vector>
#include <optional>
Expand Down Expand Up @@ -302,12 +298,8 @@ class HttpClient {
* @endcode
*/
Outcome<HttpResponse> send(const HttpRequest& request) {
#ifndef SPACETIMEDB_UNSTABLE_FEATURES
return Err<HttpResponse>("HTTP requests require SPACETIMEDB_UNSTABLE_FEATURES to be enabled");
#else
// Implemented in http_client_impl.h to avoid circular dependencies
return SendImpl(request);
#endif
}

private:
Expand All @@ -317,7 +309,7 @@ class HttpClient {
} // namespace SpacetimeDB

// Include implementation dependencies after class definition to avoid circular dependencies
#if defined(SPACETIMEDB_UNSTABLE_FEATURES) && !defined(SPACETIMEDB_HTTP_CONVERT_H)
#ifndef SPACETIMEDB_HTTP_CONVERT_H
#include "spacetimedb/logger.h"
#include "spacetimedb/http_convert.h"
#include "spacetimedb/http_client_impl.h"
Expand Down
2 changes: 0 additions & 2 deletions crates/bindings-cpp/include/spacetimedb/http_convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ inline std::pair<wire::HttpResponse, std::vector<uint8_t>> to_wire_split(const H
} // namespace convert
} // namespace SpacetimeDB

#ifdef SPACETIMEDB_UNSTABLE_FEATURES
#include "spacetimedb/logger.h"
#include "spacetimedb/http_client_impl.h"
#endif

#endif // SPACETIMEDB_HTTP_CONVERT_H
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

namespace SpacetimeDB::Internal {

#ifdef SPACETIMEDB_UNSTABLE_FEATURES

template<typename T>
struct is_outcome : std::false_type {};

Expand Down Expand Up @@ -143,8 +141,6 @@ auto try_with_tx(MakeReducerContext&& make_reducer_ctx, Func& body) -> decltype(
return result;
}

#endif

} // namespace SpacetimeDB::Internal

#endif // SPACETIMEDB_INTERNAL_TX_EXECUTION_H
8 changes: 1 addition & 7 deletions crates/bindings-cpp/include/spacetimedb/procedure_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
#include <spacetimedb/abi/FFI.h> // For transaction syscalls
#include <spacetimedb/internal/tx_execution.h>
#include <spacetimedb/random.h> // For StdbRng
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
#include <spacetimedb/http.h> // For HttpClient
#endif
#include <cstdint>
#include <functional>
#include <stdexcept>
Expand Down Expand Up @@ -66,12 +64,10 @@ struct ProcedureContext {
// Used to track which client connection initiated this procedure
ConnectionId connection_id;

#ifdef SPACETIMEDB_UNSTABLE_FEATURES
// HTTP client for making external requests
// IMPORTANT: HTTP calls are NOT allowed inside transactions!
// Always call HTTP before with_tx() or try_with_tx()
HttpClient http;
#endif

private:
// Lazily initialized RNG for UUID generation
Expand Down Expand Up @@ -173,10 +169,9 @@ struct ProcedureContext {
return Uuid::from_counter_v7(counter_uuid_, timestamp, random_bytes);
}

#ifdef SPACETIMEDB_UNSTABLE_FEATURES
/**
* @brief Execute a callback within a database transaction
*
*
* Starts a mutable transaction, executes the callback, and commits on success.
* If the callback panics (via LOG_PANIC), the transaction is automatically rolled back.
*
Expand Down Expand Up @@ -238,7 +233,6 @@ struct ProcedureContext {
};
return Internal::try_with_tx(make_reducer_ctx, body);
}
#endif
};

} // namespace SpacetimeDB
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,11 @@ Internal.TxContext inner

private ProcedureTxContext? _cached;

[Experimental("STDB_UNSTABLE")]
public Local Db => _db;

[Experimental("STDB_UNSTABLE")]
public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
base.WithTx(tx => body((ProcedureTxContext)tx));

[Experimental("STDB_UNSTABLE")]
public TxOutcome<TResult> TryWithTx<TResult, TError>(
Func<ProcedureTxContext, Result<TResult, TError>> body
)
Expand Down Expand Up @@ -252,7 +249,6 @@ public Uuid NewUuidV7()
}
}

[Experimental("STDB_UNSTABLE")]
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase
{
internal ProcedureTxContext(Internal.TxContext inner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,14 +593,11 @@ Internal.TxContext inner

private ProcedureTxContext? _cached;

[Experimental("STDB_UNSTABLE")]
public Local Db => _db;

[Experimental("STDB_UNSTABLE")]
public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
base.WithTx(tx => body((ProcedureTxContext)tx));

[Experimental("STDB_UNSTABLE")]
public TxOutcome<TResult> TryWithTx<TResult, TError>(
Func<ProcedureTxContext, Result<TResult, TError>> body
)
Expand Down Expand Up @@ -694,7 +691,6 @@ public Uuid NewUuidV7()
}
}

[Experimental("STDB_UNSTABLE")]
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase
{
internal ProcedureTxContext(Internal.TxContext inner)
Expand Down
8 changes: 2 additions & 6 deletions crates/bindings-csharp/Codegen/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2545,14 +2545,11 @@ internal ProcedureContext(Identity identity, ConnectionId? connectionId, Random

private ProcedureTxContext? _cached;

[Experimental("STDB_UNSTABLE")]
public Local Db => _db;

[Experimental("STDB_UNSTABLE")]

public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
base.WithTx(tx => body((ProcedureTxContext)tx));

[Experimental("STDB_UNSTABLE")]

public TxOutcome<TResult> TryWithTx<TResult, TError>(
Func<ProcedureTxContext, Result<TResult, TError>> body)
where TError : Exception =>
Expand Down Expand Up @@ -2643,7 +2640,6 @@ public Uuid NewUuidV7()
}
}

[Experimental("STDB_UNSTABLE")]
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase {
internal ProcedureTxContext(Internal.TxContext inner) : base(inner) {}

Expand Down
4 changes: 0 additions & 4 deletions crates/bindings-csharp/Runtime/ProcedureContext.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
namespace SpacetimeDB;

using System.Diagnostics.CodeAnalysis;

#pragma warning disable STDB_UNSTABLE
public abstract class ProcedureContextBase : Internal.IInternalProcedureContext
{
Expand Down Expand Up @@ -75,11 +73,9 @@ public TResult UnwrapOrThrow(Func<Exception> fallbackFactory) =>
IsSuccess ? Value! : throw (Error ?? fallbackFactory());
}

[Experimental("STDB_UNSTABLE")]
public TResult WithTx<TResult>(Func<ProcedureTxContextBase, TResult> body) =>
txState.WithTx(body);

[Experimental("STDB_UNSTABLE")]
public TxOutcome<TResult> TryWithTx<TResult, TError>(
Func<ProcedureTxContextBase, Result<TResult, TError>> body
)
Expand Down
11 changes: 3 additions & 8 deletions crates/bindings-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ pub mod raw {
pub fn get_jwt(connection_id_ptr: *const u8, bytes_source_id: *mut BytesSource) -> u16;
}

#[cfg(feature = "unstable")]
#[link(wasm_import_module = "spacetime_10.3")]
unsafe extern "C" {
/// Suspends execution of this WASM instance until approximately `wake_at_micros_since_unix_epoch`.
Expand Down Expand Up @@ -775,7 +774,6 @@ pub mod raw {
/// - `body_ptr` is NULL or `body_ptr[..body_len]` is not in bounds of WASM memory.
/// - `out` is NULL or `out[..size_of::<RowIter>()]` is not in bounds of WASM memory.
/// - `request_ptr[..request_len]` does not contain a valid BSATN-serialized `spacetimedb_lib::http::Request` object.
#[cfg(feature = "unstable")]
pub fn procedure_http_request(
request_ptr: *const u8,
request_len: u32,
Expand Down Expand Up @@ -1072,7 +1070,6 @@ unsafe fn call<T: Copy>(f: impl FnOnce(*mut T) -> u16) -> Result<T> {
/// Assuming the call to `f` returns 0, `Ok(())` is returned,
/// and otherwise `Err(err)` is returned.
#[inline]
#[cfg(feature = "unstable")]
fn call_no_ret(f: impl FnOnce() -> u16) -> Result<()> {
let f_code = f();
cvt(f_code)?;
Expand Down Expand Up @@ -1548,7 +1545,6 @@ impl Drop for RowIter {
}
}

#[cfg(feature = "unstable")]
pub mod procedure {
//! Side-effecting or asynchronous operations which only procedures are allowed to perform.

Expand All @@ -1566,7 +1562,7 @@ pub mod procedure {
///
/// Once complete, returns `Ok(timestamp)` on success,
/// enabling further calls that require a pending transaction,
/// or [`Errno`] otherwise.
/// or [`crate::Errno`] otherwise.
///
/// # Errors
///
Expand All @@ -1582,7 +1578,7 @@ pub mod procedure {
/// blocking until the transaction has been committed
/// and subscription queries have been run and broadcast.
///
/// Once complete, returns `Ok(())` on success, or an [`Errno`] otherwise.
/// Once complete, returns `Ok(())` on success, or an [`crate::Errno`] otherwise.
///
/// # Errors
///
Expand All @@ -1604,7 +1600,7 @@ pub mod procedure {
/// Aborts a mutable transaction,
/// blocking until the transaction has been rolled back.
///
/// Once complete, returns `Ok(())` on success, or an [`Errno`] otherwise.
/// Once complete, returns `Ok(())` on success, or an [`crate::Errno`] otherwise.
///
/// # Errors
///
Expand All @@ -1624,7 +1620,6 @@ pub mod procedure {
}

#[inline]
#[cfg(feature = "unstable")]
/// Perform an HTTP request as specified by `http_request_bsatn`,
/// suspending execution until the request is complete,
/// then return its response or error.
Expand Down
Loading
Loading