mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-07-24 11:02:22 -04:00
Deprecate ReducerContext::identity in favor of database_identity (#4843)
## Summary - add `ReducerContext::database_identity()` in Rust bindings - deprecate `ReducerContext::identity()` and keep it as a compatibility alias - update reducer docs example to use `ctx.database_identity()` - add C# reducer-context equivalent: `DatabaseIdentity` and obsolete `Identity` alias - update Rust/C# module test callsites to the new API name - update C# codegen snapshots for generated `ReducerContext` API output ## Why Issue #3201 reports user confusion between reducer `ctx.identity()` (database/module identity) and `ctx.sender`. This change clarifies naming while preserving compatibility. ## Validation - `cargo check -p spacetimedb -p module-test` (Passed) - `dotnet test crates/bindings-csharp/Codegen.Tests/Codegen.Tests.csproj --nologo` (Passed) - `dotnet test crates/bindings-csharp/Runtime.Tests/Runtime.Tests.csproj --nologo` (Failed) pre-existing unrelated failure: - `Runtime.Tests/JwtClaimsTest.cs(10,23): CS1729: 'JwtClaims' does not contain a constructor that takes 2 arguments` ## Compatibility - Rust: `identity()` still works but is deprecated in favor of `database_identity()`. - C#: `Identity` still works but is marked `[Obsolete]` in favor of `DatabaseIdentity`. Closes #3201
This commit is contained in:
@@ -280,7 +280,7 @@ SPACETIMEDB_REDUCER(list_over_age, ReducerContext ctx, uint8_t age) {
|
||||
|
||||
// Log module identity
|
||||
SPACETIMEDB_REDUCER(log_module_identity, ReducerContext ctx) {
|
||||
LOG_INFO("Module identity: " + ctx.identity().to_string());
|
||||
LOG_INFO("Module identity: " + ctx.database_identity().to_string());
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@@ -550,8 +550,8 @@ SPACETIMEDB_REDUCER(test_btree_index_args, ReducerContext ctx) {
|
||||
|
||||
// Test reducer for assertions
|
||||
SPACETIMEDB_REDUCER(assert_caller_identity_is_module_identity, ReducerContext ctx) {
|
||||
LOG_INFO("Sender: " + ctx.sender().to_string() + " Identity: " + ctx.identity().to_string());
|
||||
if (ctx.sender() != ctx.identity()) {
|
||||
LOG_INFO("Sender: " + ctx.sender().to_string() + " Identity: " + ctx.database_identity().to_string());
|
||||
if (ctx.sender() != ctx.database_identity()) {
|
||||
LOG_ERROR("Assertion failed: caller identity does not match module identity");
|
||||
} else {
|
||||
LOG_INFO("Assertion passed: caller identity matches module identity");
|
||||
@@ -693,7 +693,7 @@ SPACETIMEDB_PROCEDURE(Unit, with_tx, ProcedureContext ctx) {
|
||||
|
||||
// Hit SpacetimeDB's schema HTTP route and return its result as a string
|
||||
SPACETIMEDB_PROCEDURE(std::string, get_my_schema_via_http, ProcedureContext ctx) {
|
||||
Identity module_identity = ctx.identity();
|
||||
Identity module_identity = ctx.database_identity();
|
||||
std::string url = "http://localhost:3000/v1/database/" + module_identity.to_string() + "/schema?version=9";
|
||||
|
||||
auto result = ctx.http.get(url);
|
||||
|
||||
Reference in New Issue
Block a user