@radishbot/sdk 0.3.0 → 0.3.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.
- package/README.md +2 -2
- package/package.json +1 -1
- package/src/index.ts +8 -0
package/README.md
CHANGED
|
@@ -151,9 +151,9 @@ const root = await RL(key, { release: process.env.GIT_SHA });
|
|
|
151
151
|
|
|
152
152
|
Sub-flows inherit the release from the root automatically.
|
|
153
153
|
|
|
154
|
-
## Retention
|
|
154
|
+
## Retention
|
|
155
155
|
|
|
156
|
-
Each key has a retention period. Flows older than the retention window are automatically
|
|
156
|
+
Each key has a retention period. Flows older than the retention window are automatically cleaned up.
|
|
157
157
|
|
|
158
158
|
```ts
|
|
159
159
|
const root = await RL(key, { retention: "30d" }); // default
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -153,12 +153,20 @@ export class Flow {
|
|
|
153
153
|
this._drain(); // flush any logs queued before ready
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/** Max pending logs before oldest are dropped (prevents memory issues at high volume) */
|
|
157
|
+
private static MAX_PENDING = 10_000;
|
|
158
|
+
|
|
156
159
|
/** Log a message with optional data */
|
|
157
160
|
log(message: string, data?: unknown, level: LogLevel = "info"): this {
|
|
158
161
|
if (this._finished) {
|
|
159
162
|
console.warn(`[radish] Cannot log to finished flow`);
|
|
160
163
|
return this;
|
|
161
164
|
}
|
|
165
|
+
// Drop oldest logs if buffer is full (backpressure)
|
|
166
|
+
if (this._pendingLogs.length >= Flow.MAX_PENDING) {
|
|
167
|
+
const dropped = this._pendingLogs.length - Flow.MAX_PENDING + 1;
|
|
168
|
+
this._pendingLogs.splice(0, dropped);
|
|
169
|
+
}
|
|
162
170
|
this._pendingLogs.push({
|
|
163
171
|
level,
|
|
164
172
|
message,
|