sample method

LatencySample sample(
  1. String touchpoint,
  2. int callIndex,
  3. WorldLatencyBands bands
)

Sample the latency for touchpoint's callIndex (1-based) under the declared bands.

Implementation

LatencySample sample(
  String touchpoint,
  int callIndex,
  WorldLatencyBands bands,
) {
  final band = _bandFor(callIndex, bands);
  final (min, max) = switch (band) {
    LatencyBand.fast => (bands.fastMinMs, bands.fastMaxMs),
    LatencyBand.slow => (bands.slowMinMs, bands.slowMaxMs),
    LatencyBand.timeout => (bands.timeoutMinMs, bands.timeoutMaxMs),
  };
  return LatencySample(_rng.nextInt(min, max), band);
}