Skip to content

Commit 468f661

Browse files
committed
[docs/release]: Revert "Implement HTTP handlers / webhooks in Rust modules (#4636)"
This reverts commit 5c04860.
1 parent c70d002 commit 468f661

143 files changed

Lines changed: 736 additions & 9591 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

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

crates/bindings-cpp/CMakeLists.txt

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ target_sources(spacetimedb_cpp_library PRIVATE ${LIBRARY_SOURCES})
3030

3131
# Require C++20 for consumers of this library without forcing global flags
3232
target_compile_features(spacetimedb_cpp_library PUBLIC cxx_std_20)
33-
target_compile_definitions(spacetimedb_cpp_library PRIVATE SPACETIMEDB_UNSTABLE_FEATURES)
3433

3534
# Set include directories
3635
target_include_directories(spacetimedb_cpp_library
@@ -61,5 +60,46 @@ if(PROJECT_IS_TOP_LEVEL)
6160
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6261
endif()
6362

64-
# Unit/compile/smoke test harnesses live under `tests/` as standalone runners
65-
# rather than being built through the top-level library CMake target.
63+
# ---- Tests ----
64+
# Default: ON only when building this project directly; OFF when used via FetchContent/add_subdirectory
65+
if(CMAKE_VERSION VERSION_LESS 3.21)
66+
# Fallback heuristic for older CMake
67+
set(_is_top_level FALSE)
68+
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
69+
set(_is_top_level TRUE)
70+
endif()
71+
else()
72+
set(_is_top_level ${PROJECT_IS_TOP_LEVEL})
73+
endif()
74+
75+
option(BUILD_TESTS "Build the test suite" ${_is_top_level})
76+
77+
if(BUILD_TESTS AND NOT CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
78+
enable_testing()
79+
80+
# Add test executable
81+
add_executable(test_bsatn tests/main.cpp tests/module_library_unit_tests.cpp)
82+
83+
# Link against the module library
84+
target_link_libraries(test_bsatn PRIVATE spacetimedb_cpp_library)
85+
86+
# Set C++20 standard for tests
87+
target_compile_features(test_bsatn PRIVATE cxx_std_20)
88+
89+
# Add test to CTest
90+
add_test(NAME bsatn_tests COMMAND test_bsatn)
91+
92+
# Add verbose test variant
93+
add_test(NAME bsatn_tests_verbose COMMAND test_bsatn -v)
94+
95+
# Set test properties
96+
set_tests_properties(bsatn_tests PROPERTIES
97+
TIMEOUT 30
98+
LABELS "unit"
99+
)
100+
101+
set_tests_properties(bsatn_tests_verbose PROPERTIES
102+
TIMEOUT 30
103+
LABELS "unit;verbose"
104+
)
105+
endif()

crates/bindings-cpp/include/spacetimedb.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@
126126

127127
// Procedure context and macros
128128
#include "spacetimedb/procedure_macros.h"
129-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
130-
#include "spacetimedb/handler_context.h"
131-
#include "spacetimedb/router.h"
132-
#include "spacetimedb/http_handler_macros.h"
133-
#endif
134129

135130
// =============================================================================
136131
// VIEW SYSTEM

crates/bindings-cpp/include/spacetimedb/abi/abi.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -216,37 +216,6 @@ int16_t __call_reducer__(
216216
BytesSource args,
217217
BytesSink error);
218218

219-
STDB_EXPORT(__call_view__)
220-
int16_t __call_view__(
221-
uint32_t id,
222-
uint64_t sender_0, uint64_t sender_1, uint64_t sender_2, uint64_t sender_3,
223-
BytesSource args,
224-
BytesSink result);
225-
226-
STDB_EXPORT(__call_view_anon__)
227-
int16_t __call_view_anon__(
228-
uint32_t id,
229-
BytesSource args,
230-
BytesSink result);
231-
232-
STDB_EXPORT(__call_procedure__)
233-
int16_t __call_procedure__(
234-
uint32_t id,
235-
uint64_t sender_0, uint64_t sender_1, uint64_t sender_2, uint64_t sender_3,
236-
uint64_t conn_id_0, uint64_t conn_id_1,
237-
uint64_t timestamp_microseconds,
238-
BytesSource args_source,
239-
BytesSink result_sink);
240-
241-
STDB_EXPORT(__call_http_handler__)
242-
int16_t __call_http_handler__(
243-
uint32_t id,
244-
uint64_t timestamp_microseconds,
245-
BytesSource request_source,
246-
BytesSource request_body_source,
247-
BytesSink response_sink,
248-
BytesSink response_body_sink);
249-
250219
// ========================================================================
251220
// WASI SHIMS
252221
// ========================================================================

crates/bindings-cpp/include/spacetimedb/handler_context.h

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

crates/bindings-cpp/include/spacetimedb/http.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
#pragma once
55

6-
#ifndef SPACETIMEDB_UNSTABLE_FEATURES
7-
#error "spacetimedb/http.h requires SPACETIMEDB_UNSTABLE_FEATURES to be enabled"
8-
#endif
9-
106
#include <string>
117
#include <vector>
128
#include <optional>
@@ -316,10 +312,8 @@ class HttpClient {
316312

317313
} // namespace SpacetimeDB
318314

319-
// Include implementation dependencies after class definition to avoid circular dependencies
320-
#if defined(SPACETIMEDB_UNSTABLE_FEATURES) && !defined(SPACETIMEDB_HTTP_CONVERT_H)
321-
#include "spacetimedb/logger.h"
322-
#include "spacetimedb/http_convert.h"
315+
// Include implementation after class definition to avoid circular dependencies
316+
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
323317
#include "spacetimedb/http_client_impl.h"
324318
#endif
325319

crates/bindings-cpp/include/spacetimedb/http_client_impl.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "spacetimedb/http_convert.h"
88
#include "spacetimedb/abi/abi.h"
99
#include "spacetimedb/bsatn/bsatn.h"
10-
#include "spacetimedb/internal/runtime_registration.h"
10+
#include "spacetimedb/internal/Module.h"
1111

1212
namespace SpacetimeDB {
1313

@@ -23,9 +23,9 @@ inline Outcome<HttpResponse> HttpClient::SendImpl(const HttpRequest& request) {
2323
// Prepare body bytes
2424
const std::vector<uint8_t>& body_bytes = request.body.bytes;
2525

26-
// The host ABI requires a non-null, in-bounds body pointer even when body_len == 0.
27-
static const uint8_t empty_sentinel = 0;
28-
const uint8_t* body_ptr = body_bytes.empty() ? &empty_sentinel : body_bytes.data();
26+
// Call host function
27+
// Note: For empty body, we need to pass a valid pointer, not null
28+
const uint8_t* body_ptr = body_bytes.empty() ? reinterpret_cast<const uint8_t*>("") : body_bytes.data();
2929

3030
BytesSource out[2] = {BytesSource{0}, BytesSource{0}};
3131
Status status = procedure_http_request(
@@ -40,11 +40,15 @@ inline Outcome<HttpResponse> HttpClient::SendImpl(const HttpRequest& request) {
4040
if (status.inner == 21) {
4141
// Read error message from out[0]
4242
std::vector<uint8_t> error_bytes = Internal::ConsumeBytes(out[0]);
43-
43+
44+
LOG_INFO("HTTP: Error bytes: " + std::to_string(error_bytes.size()));
45+
4446
// Decode BSATN string
4547
bsatn::Reader reader(error_bytes.data(), error_bytes.size());
4648
std::string error_message = bsatn::deserialize<std::string>(reader);
4749

50+
LOG_INFO("HTTP: Error message: " + error_message);
51+
4852
return Err<HttpResponse>(std::move(error_message));
4953
}
5054

@@ -53,6 +57,7 @@ inline Outcome<HttpResponse> HttpClient::SendImpl(const HttpRequest& request) {
5357
return Err<HttpResponse>("HTTP requests are blocked inside transactions. Call HTTP before with_tx() or try_with_tx().");
5458
}
5559

60+
LOG_INFO("HTTP: Unknown error code: " + std::to_string(status.inner));
5661
return Err<HttpResponse>("HTTP request failed with status code: " + std::to_string(status.inner));
5762
}
5863

crates/bindings-cpp/include/spacetimedb/http_convert.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,6 @@ inline HttpRequest from_wire(const wire::HttpRequest& request) {
237237
return result;
238238
}
239239

240-
inline HttpRequest from_wire(const wire::HttpRequest& request, std::vector<uint8_t> body) {
241-
HttpRequest result = from_wire(request);
242-
result.body.bytes = std::move(body);
243-
return result;
244-
}
245-
246240
// ==================== HttpResponse Conversions ====================
247241

248242
/**
@@ -274,16 +268,7 @@ inline HttpResponse from_wire(const wire::HttpResponse& response) {
274268
return result;
275269
}
276270

277-
inline std::pair<wire::HttpResponse, std::vector<uint8_t>> to_wire_split(const HttpResponse& response) {
278-
return {to_wire(response), response.body.bytes};
279-
}
280-
281271
} // namespace convert
282272
} // namespace SpacetimeDB
283273

284-
#ifdef SPACETIMEDB_UNSTABLE_FEATURES
285-
#include "spacetimedb/logger.h"
286-
#include "spacetimedb/http_client_impl.h"
287-
#endif
288-
289274
#endif // SPACETIMEDB_HTTP_CONVERT_H

crates/bindings-cpp/include/spacetimedb/http_handler_macros.h

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

0 commit comments

Comments
 (0)