Skip to content

Commit e7e6a1c

Browse files
committed
docs(core): add documentation for buffer management
1 parent e4d843d commit e7e6a1c

1 file changed

Lines changed: 72 additions & 1 deletion

File tree

src/types/pluginOptions.ts

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,83 @@ export type CollectionConfig = {
463463
*
464464
* ---
465465
* ## ⚠️ Critical Notes
466-
* -
466+
* - These settings are very important, to change these settings, consider all aspects including RAM and server power.
467467
*
468468
*/
469469
buffer?: {
470+
/**
471+
* 📝 The basics of injecting logs into the database
472+
*
473+
*
474+
*
475+
* @default "time"
476+
*
477+
*
478+
* 📦 Usage Example
479+
*
480+
* @example <caption>🧪 Data injection based on log count</caption>
481+
* ```ts
482+
* flushStrategy: 'size',
483+
* ```
484+
* ### ⚠️ Critical Notes
485+
* - If you use the size method, your logs will be stored in RAM before being injected into the database.
486+
*
487+
*/
470488
flushStrategy?: 'realtime' | 'size' | 'time'
489+
/**
490+
* 📝 Maximum number of logs before injection
491+
*
492+
* 📖 If the number of logs stored in the buffer memory reaches this number, data will be injected.
493+
*
494+
* 📌@type {number}
495+
*
496+
* @default 10
497+
*
498+
*
499+
* 📦 Usage Example
500+
*
501+
* @example <caption>🧪 Up to 18 logs can be stored in memory</caption>
502+
* ```ts
503+
* size: 18
504+
* ```
505+
*
506+
* ---
507+
* ### ⚠️ Critical Notes
508+
* - Works when flushStrategy is equal to size
509+
* - If you enter the number 1, use the realtime method and do not define a value for this.
510+
* ```ts
511+
* flushStrategy: 'realtime',
512+
* ```
513+
* - Very high numbers will increase RAM usage.
514+
* - If you set a high number and on the other hand the logs produced are low, the logs will be recorded later.
515+
*
516+
*/
471517
size?: number
518+
/**
519+
* 📝 Maximum time to inject logs into the buffer relative to the last injection
520+
*
521+
*
522+
* 📌@type {Duration}
523+
*
524+
* @default "5s"
525+
*
526+
*
527+
* 📦 Usage Example
528+
*
529+
* @example <caption>🧪 Inject logs every 1 minute</caption>
530+
* ```ts
531+
* time: "1m"
532+
* ```
533+
*
534+
* ---
535+
* ### ⚠️ Critical Notes
536+
* - If you want to enter a value of "1s", set the flushStrategy value to time instead and do not define a value for the time property.
537+
* ```ts
538+
* flushStrategy: 'realtime',
539+
* ```
540+
* - If you set the time too low, the CPU will be severely affected.
541+
* - If you allow too much time, the logs will be recorded later. If the server crashes, the logs will be lost.
542+
*/
472543
time?: Duration
473544
}
474545

0 commit comments

Comments
 (0)