diff --git a/libs/common/src/tools/generator/default-generator.service.ts b/libs/common/src/tools/generator/default-generator.service.ts index cec8b75f0c..9decb309be 100644 --- a/libs/common/src/tools/generator/default-generator.service.ts +++ b/libs/common/src/tools/generator/default-generator.service.ts @@ -1,4 +1,4 @@ -import { firstValueFrom, share, timer, ReplaySubject, Observable } from "rxjs"; +import { firstValueFrom, Observable } from "rxjs"; // FIXME: use index.ts imports once policy abstractions and models // implement ADR-0002 @@ -7,13 +7,6 @@ import { UserId } from "../../types/guid"; import { GeneratorStrategy, GeneratorService, PolicyEvaluator } from "./abstractions"; -type DefaultGeneratorServiceTuning = { - /* amount of time to keep the most recent policy after a subscription ends. Once the - * cache expires, the ignoreQty and timeoutMs settings apply to the next lookup. - */ - policyCacheMs: number; -}; - /** {@link GeneratorServiceAbstraction} */ export class DefaultGeneratorService implements GeneratorService { /** Instantiates the generator service @@ -24,18 +17,8 @@ export class DefaultGeneratorService implements GeneratorServic constructor( private strategy: GeneratorStrategy, private policy: PolicyService, - tuning: Partial = {}, - ) { - this.tuning = Object.assign( - { - // a minute - policyCacheMs: 60000, - }, - tuning, - ); - } + ) {} - private tuning: DefaultGeneratorServiceTuning; private _evaluators$ = new Map>>(); /** {@link GeneratorService.options$} */ @@ -69,13 +52,6 @@ export class DefaultGeneratorService implements GeneratorServic const evaluator$ = this.policy.getAll$(this.strategy.policy, userId).pipe( // create the evaluator from the policies this.strategy.toEvaluator(), - - // cache evaluator in a replay subject to amortize creation cost - // and reduce GC pressure. - share({ - connector: () => new ReplaySubject(1), - resetOnRefCountZero: () => timer(this.tuning.policyCacheMs), - }), ); return evaluator$; diff --git a/libs/tools/generator/core/src/services/default-generator.service.ts b/libs/tools/generator/core/src/services/default-generator.service.ts index a577acd734..4fb46f5611 100644 --- a/libs/tools/generator/core/src/services/default-generator.service.ts +++ b/libs/tools/generator/core/src/services/default-generator.service.ts @@ -1,4 +1,4 @@ -import { firstValueFrom, share, timer, ReplaySubject, Observable } from "rxjs"; +import { firstValueFrom, Observable } from "rxjs"; // FIXME: use index.ts imports once policy abstractions and models // implement ADR-0002 @@ -7,13 +7,6 @@ import { UserId } from "@bitwarden/common/types/guid"; import { GeneratorStrategy, GeneratorService, PolicyEvaluator } from "../abstractions"; -type DefaultGeneratorServiceTuning = { - /* amount of time to keep the most recent policy after a subscription ends. Once the - * cache expires, the ignoreQty and timeoutMs settings apply to the next lookup. - */ - policyCacheMs: number; -}; - /** {@link GeneratorServiceAbstraction} */ export class DefaultGeneratorService implements GeneratorService { /** Instantiates the generator service @@ -24,18 +17,8 @@ export class DefaultGeneratorService implements GeneratorServic constructor( private strategy: GeneratorStrategy, private policy: PolicyService, - tuning: Partial = {}, - ) { - this.tuning = Object.assign( - { - // a minute - policyCacheMs: 60000, - }, - tuning, - ); - } + ) {} - private tuning: DefaultGeneratorServiceTuning; private _evaluators$ = new Map>>(); /** {@link GeneratorService.options$} */ @@ -69,13 +52,6 @@ export class DefaultGeneratorService implements GeneratorServic const evaluator$ = this.policy.getAll$(this.strategy.policy, userId).pipe( // create the evaluator from the policies this.strategy.toEvaluator(), - - // cache evaluator in a replay subject to amortize creation cost - // and reduce GC pressure. - share({ - connector: () => new ReplaySubject(1), - resetOnRefCountZero: () => timer(this.tuning.policyCacheMs), - }), ); return evaluator$;