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(String, Class, ThrowingSupplier).

You MUST NOT use this object inside a Context.run(String, Class, ThrowingSupplier)/Context.runAsync(String, Class, ThrowingSupplier).

See Also:
  • Method Details Link icon

    • setSeed Link icon

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

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

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