Class RestateRandom

java.lang.Object
java.util.Random
dev.restate.sdk.RestateRandom
All Implemented Interfaces:
Serializable, RandomGenerator

public class RestateRandom extends Random
Subclass of Random inherently predictable, seeded on the InvocationId, which is not secret.

This instance is useful to generate identifiers, idempotency keys, and for uniform sampling from a set of options. If a cryptographically secure value is needed, please generate that externally using Context.run(Serde, ThrowingSupplier).

You MUST NOT use this object inside a Context.run(Serde, ThrowingSupplier).

See Also:
  • Method Details

    • setSeed

      public void setSeed(long seed)
      Overrides:
      setSeed in class Random
      Throws:
      UnsupportedOperationException - You cannot set the seed on RestateRandom
    • nextUUID

      public UUID nextUUID()
      Returns:
      a UUID generated using this RNG that is stable across retries and replays.
    • next

      protected int next(int bits)
      Overrides:
      next in class Random