Class DurableRandom
- Namespace
- Restate.Sdk
- Assembly
- Restate.Sdk.dll
Deterministic random number generator seeded per invocation. Produces the same sequence on every replay, making it safe for durable execution.
public sealed class DurableRandom
- Inheritance
-
DurableRandom
- Inherited Members
Remarks
From service protocol V6 the seed is the random_seed the server sends on the
StartMessage. That field does not exist below V6, so on a V5 stream the seed is derived
from the invocation id instead: SHA-256 of the raw invocation id, read as a big-endian
64-bit integer. That derivation is the sha2_random_seed feature of
sdk-shared-core, which is off by default and enabled by the Python, Rust and Ruby
SDKs but not by TypeScript. The seed is folded to 32 bits for the underlying generator,
so sequences still differ between SDKs even where the 64-bit seed agrees.
Methods
Next()
Returns a non-negative random integer.
public int Next()
Returns
Next(int)
Returns a non-negative random integer less than maxExclusive.
public int Next(int maxExclusive)
Parameters
maxExclusiveint
Returns
Next(int, int)
Returns a random integer within the specified range.
public int Next(int minInclusive, int maxExclusive)
Parameters
Returns
NextDouble()
Returns a random double between 0.0 and 1.0.
public double NextDouble()
Returns
NextGuid()
Returns a deterministic version-4 GUID (RFC 4122).
public Guid NextGuid()