@huevo/plugin-retry 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +33 -0
  2. package/package.json +11 -3
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @huevo/plugin-retry
2
+
3
+ Авторетраи на slow-рейт-лимиты для [huevo](https://www.npmjs.com/package/huevo).
4
+
5
+ Любой эндпоинт huevo.su может ответить `{"error":"slow","retry":N}` — плагин
6
+ ждёт `retry` секунд и повторяет запрос сам, незаметно для вашего кода.
7
+
8
+ ```
9
+ npm i huevo @huevo/plugin-retry
10
+ ```
11
+
12
+ ```ts
13
+ import { Huevo } from "huevo";
14
+ import { retry } from "@huevo/plugin-retry";
15
+
16
+ const huevo = Huevo.fromToken(session);
17
+ huevo.use(retry({ maxRetries: 5 }));
18
+
19
+ await huevo.clicker.post(400); // slow? подождёт и повторит — вы этого не заметите
20
+ ```
21
+
22
+ ## опции
23
+
24
+ | Опция | По умолчанию | Описание |
25
+ |---|---|---|
26
+ | `maxRetries` | `3` | максимум повторов подряд на один запрос |
27
+ | `margin` | `1` | запас к `retry`-секундам сервера, сек |
28
+ | `onRetry` | — | колбэк `(waitMs, opts, attempt)` перед каждым повтором |
29
+
30
+ Работает через response-интерцепторы ядра (`huevo.http.interceptors`) — ядро
31
+ не содержит логики ретраев, плагин добавляет её снаружи.
32
+
33
+ [Репозиторий](https://github.com/neverlane/huevo/tree/master/packages/retry) · MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huevo/plugin-retry",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Авторетраи на slow-рейт-лимиты для huevo SDK",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -11,12 +11,20 @@
11
11
  "import": "./dist/index.js"
12
12
  }
13
13
  },
14
- "files": ["dist"],
14
+ "files": [
15
+ "dist"
16
+ ],
15
17
  "scripts": {
16
18
  "build": "tsc -p tsconfig.json"
17
19
  },
18
20
  "license": "MIT",
19
21
  "peerDependencies": {
20
22
  "huevo": "^0.1.0"
21
- }
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/neverlane/huevo.git",
27
+ "directory": "packages/retry"
28
+ },
29
+ "homepage": "https://github.com/neverlane/huevo/tree/master/packages/retry"
22
30
  }