Class GrpcChaosDecision

java.lang.Object
org.mockserver.mock.action.http.GrpcChaosDecision

public class GrpcChaosDecision extends Object
Evaluates a GrpcChaosProfile against the current request context (match count, quota state) and decides whether to inject a gRPC fault. Returns either null (no fault, pass through to normal handling) or a GrpcChaosDecision.GrpcFault describing the gRPC status code and message to inject.

Decision priority:

  1. Count window: if the match count is outside the eligible window, no fault is injected.
  2. Quota: if quota fields are configured and the limit is exceeded, RESOURCE_EXHAUSTED is returned deterministically.
  3. Probability: if a seeded/unseeded random draw is below errorProbability, the configured (or default UNAVAILABLE) error status is returned.
  • Method Details

    • evaluate

      public static GrpcChaosDecision.GrpcFault evaluate(GrpcChaosProfile profile, int matchCount, HttpQuotaRegistry quotaRegistry)
      Evaluate the given profile and decide whether to inject a gRPC fault.
      Parameters:
      profile - the gRPC chaos profile (must not be null)
      matchCount - 1-based per-service match count
      quotaRegistry - the quota registry for deterministic rate limiting (may be null for no-quota scenarios)
      Returns:
      a GrpcChaosDecision.GrpcFault to inject, or null if no fault should be injected