mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-13 11:17:50 -04:00
bba6f89e5f
# Description of Changes This is the implementation of #4255 This is a rebuild of #4262 after a rebase throughly messed up that PR's changelog, this time under `master` branch. * Refactored `Module` so all V10 builder state and registration helpers now live on `partial class RawModuleDefV10`. The static `Module` class simply registers components against that builder and serializes via `moduleDef.BuildModuleDefinition()` * Removed the deprecated `__describe_module__` export. Only `__describe_module_v10__` is emitted now across the runtime, native shim, generated bindings, and snapshots * Mirrored the Rust TODO that future V10 sections will cover Event tables and Case-conversion policy so we don't lose track of those items Event Tables will be added once they are finished being implemented. # API and ABI breaking changes Modules built with these bindings now expose only `__describe_module_v10__` The legacy `__describe_module__` symbol is gone from both managed and native layers. Hosts expecting the old export must switch to the V10 entry point (which is already the canonical ABI for 2.0). # Expected complexity level and risk 2 - Low. The refactor keeps the previous builder logic but relocates it, and the export removal matches the already-supported V10 host path. # Testing - [X] Successfully built CLI and DLLs without errors. - [X] Ran `dotnet build crates/bindings-csharp/Runtime/Runtime.csproj` without errors. - [X] Ran `dotnet test crates/bindings-csharp/Codegen.Tests/Codegen.Tests.csproj` without errors. - [X] Ran `bash run-regression-tests.sh` without errors. --------- Co-authored-by: clockwork-labs-bot <clockwork-labs-bot@users.noreply.github.com>
78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
namespace SpacetimeDB.Internal;
|
|
|
|
using System;
|
|
using System.IO;
|
|
using System.Text;
|
|
using SpacetimeDB.BSATN;
|
|
|
|
/// <summary>
|
|
/// Represents a procedure that can be registered and invoked by the module runtime.
|
|
/// </summary>
|
|
public interface IProcedure
|
|
{
|
|
/// <summary>
|
|
/// Creates a procedure definition for registration with the module system.
|
|
/// </summary>
|
|
RawProcedureDefV10 MakeProcedureDef(ITypeRegistrar registrar);
|
|
|
|
/// <summary>
|
|
/// Invokes the procedure with the given arguments and context.
|
|
/// </summary>
|
|
byte[] Invoke(BinaryReader reader, IProcedureContext ctx);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents the context for a procedure call.
|
|
/// </summary>
|
|
public interface IProcedureContext
|
|
{
|
|
/// <summary>
|
|
/// Gets the identity of the current procedure caller.
|
|
/// </summary>
|
|
/// <returns>The identity of the caller.</returns>
|
|
public static Identity GetIdentity()
|
|
{
|
|
FFI.identity(out var identity);
|
|
return identity;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Internal interface for procedure context with additional functionality.
|
|
/// </summary>
|
|
public interface IInternalProcedureContext : IProcedureContext
|
|
{
|
|
TxContext EnterTxContext(long timestampMicros);
|
|
void ExitTxContext();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Provides utility methods for procedure-related functionality.
|
|
/// </summary>
|
|
public static class ProcedureExtensions
|
|
{
|
|
/// <summary>
|
|
/// Schedules an immediate volatile, non-atomic procedure call.
|
|
/// </summary>
|
|
public static void VolatileNonatomicScheduleImmediate(string name, MemoryStream args)
|
|
{
|
|
var name_bytes = Encoding.UTF8.GetBytes(name);
|
|
var args_bytes = args.ToArray();
|
|
|
|
try
|
|
{
|
|
FFI.volatile_nonatomic_schedule_immediate(
|
|
name_bytes,
|
|
(uint)name_bytes.Length,
|
|
args_bytes,
|
|
(uint)args_bytes.Length
|
|
);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Log.Error($"Failed to schedule procedure {name}: {ex}");
|
|
throw;
|
|
}
|
|
}
|
|
}
|