LatentiePlugin

Hiermee worden reacties met een willekeurig aantal milliseconden uit het geconfigureerde bereik vertraagd. Ondersteunt zowel HTTP-aanvragen als STDIO-communicatie.

Dev Proxy latentie simuleren voor een API-aanvraag.

Configuratievoorbeeld

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "LatencyPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "latencyPlugin"
    }
  ],
  "latencyPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/latencyplugin.schema.json",
    "minMs": 200,
    "maxMs": 10000
  }
}

Configuratie-eigenschappen

Eigenschap Beschrijving Verstek
minMs De minimale hoeveelheid vertraging die is toegevoegd aan een aanvraag in milliseconden. Moet kleiner dan of gelijk zijn aan maxMs. 0
maxMs De maximale hoeveelheid vertraging die is toegevoegd aan een aanvraag in milliseconden. 5.000

Opdrachtregelopties

Geen

Remarks

Dev Proxy valideert de configuratie van de invoegtoepassing wanneer deze wordt gestart. Als minMs deze groter is dan maxMs, wordt de dev-proxy niet gestart en wordt een fout weergegeven, bijvoorbeeld:

LatencyPlugin: minMs (500) must be less than or equal to maxMs (100).

Als u een vaste vertraging wilt toevoegen, stelt u deze in minMs en maxMs op dezelfde waarde.

STDIO-ondersteuning

Wanneer u de LatencyPluginstdio opdracht gebruikt, voegt de invoegtoepassing kunstmatige latentie toe aan stdout-antwoorden. Het simuleren van latentie is handig om te testen hoe uw toepassing trage MCP-serverreacties (Model Context Protocol) of andere op STDIO gebaseerde hulpprogramma's verwerkt.

Configuratievoorbeeld voor STDIO

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/rc.schema.json",
  "plugins": [
    {
      "name": "LatencyPlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "latencyPlugin"
    },
    {
      "name": "MockStdioResponsePlugin",
      "enabled": true,
      "pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
      "configSection": "mockStdioResponsePlugin"
    }
  ],
  "latencyPlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/latencyplugin.schema.json",
    "minMs": 100,
    "maxMs": 500
  },
  "mockStdioResponsePlugin": {
    "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v4.0.0/mockstdioresponseplugin.schema.json",
    "mocksFile": "stdio-mocks.json"
  }
}

Voer vervolgens het volgende uit:

devproxy stdio npx -y @modelcontextprotocol/server-filesystem

Volgende stap