(
trySend: TrySend,
storage: StoreInterface,
config: Config,
log: Logger,
createStore: CreateStore,
getAttrs: () => s.AttrsStore,
)
| 445 | private getAttrs: () => s.AttrsStore; |
| 446 | |
| 447 | constructor( |
| 448 | trySend: TrySend, |
| 449 | storage: StoreInterface, |
| 450 | config: Config, |
| 451 | log: Logger, |
| 452 | createStore: CreateStore, |
| 453 | getAttrs: () => s.AttrsStore, |
| 454 | ) { |
| 455 | this.trySend = trySend; |
| 456 | this.config = config; |
| 457 | this.log = log; |
| 458 | this.createStore = createStore; |
| 459 | this.getAttrs = getAttrs; |
| 460 | |
| 461 | this.subs = new PersistedObject<string, Sub, SubInStorage>({ |
| 462 | persister: storage, |
| 463 | merge: onMergeSub, |
| 464 | serialize: syncSubToStorage, |
| 465 | parse: (_key, x) => syncSubFromStorage(x, this.config.useDateObjects), |
| 466 | objectSize: (sub) => sub.values?.entities.length || 0, |
| 467 | logger: log, |
| 468 | gc: { |
| 469 | maxAgeMs: 1000 * 60 * 60 * 24 * 7 * 52, // 1 year |
| 470 | maxEntries: 1000, |
| 471 | // Size of each sub is the number of entity |
| 472 | maxSize: 1_000_000, // 1 million entities |
| 473 | }, |
| 474 | }); |
| 475 | } |
| 476 | |
| 477 | public beforeUnload() { |
| 478 | this.subs.flush(); |
nothing calls this directly
no test coverage detected