Skip to content

Commit fc29d27

Browse files
committed
Remove firestore collection in favor of using memory and firestore cache
1 parent e570e06 commit fc29d27

37 files changed

Lines changed: 1415 additions & 2277 deletions

apps/payments/api/.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,8 @@ METERING_CONFIG__CLOUD_TASKS__THRESHOLD__BUCKET_SIZE_MS=300000
106106
METERING_CONFIG__CLOUD_TASKS__THRESHOLD__SCHEDULE_DELAY_MS=420000
107107

108108
# Free Access Program Client Config
109-
# NB: This needs to match config in payments-next
110-
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__COLLECTION_NAME=subplat-free-access-program
109+
# NB: Ideally this matches the config in payments-next
110+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__FIRESTORE_CACHE_COLLECTION_NAME=subplat-free-access-program-cache
111+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__MEM_CACHE_T_T_L=300 # 5 minutes
112+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__FIRESTORE_CACHE_TTL=1800 # 30 minutes
113+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__FIRESTORE_OFFLINE_CACHE_TTL=604800 # 7 days

apps/payments/api/src/app/app.module.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,7 @@ import {
4949
PaypalCustomerManager,
5050
} from '@fxa/payments/paypal';
5151
import { CurrencyManager } from '@fxa/payments/currency';
52-
import {
53-
AuthServerEmailCapabilityClient,
54-
FreeAccessProgramManager,
55-
FreeAccessProgramNotifierService,
56-
FreeAccessProgramReconcilerService,
57-
FreeAccessProgramWebhookController,
58-
FreeAccessProgramWebhookService,
59-
} from '@fxa/free-access-program';
52+
import { FreeAccessProgramManager } from '@fxa/free-access-program';
6053
import { AccountDatabaseNestFactory } from '@fxa/shared/db/mysql/account';
6154
import { AccountManager } from '@fxa/shared/account/account';
6255
import { CartManager } from '@fxa/payments/cart';
@@ -92,7 +85,6 @@ import { PaymentsMetricsAggregatorService } from '@fxa/payments/metrics-aggregat
9285
AppController,
9386
BillingAndSubscriptionsController,
9487
CmsWebhooksController,
95-
FreeAccessProgramWebhookController,
9688
FxaWebhooksController,
9789
StripeWebhooksController,
9890
],
@@ -115,12 +107,8 @@ import { PaymentsMetricsAggregatorService } from '@fxa/payments/metrics-aggregat
115107
PaymentsEmitterService,
116108
PriceManager,
117109
ProductManager,
118-
AuthServerEmailCapabilityClient,
119110
FirestoreProvider,
120111
FreeAccessProgramManager,
121-
FreeAccessProgramNotifierService,
122-
FreeAccessProgramReconcilerService,
123-
FreeAccessProgramWebhookService,
124112
GoogleIapClient,
125113
GoogleIapPurchaseManager,
126114
StatsDProvider,

apps/payments/api/src/config/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ import { IsDefined, ValidateNested } from 'class-validator';
33

44
import { CurrencyConfig } from '@fxa/payments/currency';
55
import { MeteringConfig } from '@fxa/entitlements/metering';
6-
import {
7-
AuthServerEmailCapabilityConfig,
8-
FreeAccessProgramClientConfig,
9-
} from '@fxa/free-access-program';
6+
import { FreeAccessProgramClientConfig } from '@fxa/free-access-program';
107
import { AppleIapClientConfig, GoogleIapClientConfig } from '@fxa/payments/iap';
118
import { PaymentsGleanConfig } from '@fxa/payments/metrics';
129
import { PaypalClientConfig } from '@fxa/payments/paypal';
@@ -93,9 +90,4 @@ export class RootConfig {
9390
@ValidateNested()
9491
@IsDefined()
9592
public readonly freeAccessProgramClientConfig!: Partial<FreeAccessProgramClientConfig>;
96-
97-
@Type(() => AuthServerEmailCapabilityConfig)
98-
@ValidateNested()
99-
@IsDefined()
100-
public readonly authServerEmailCapabilityConfig!: Partial<AuthServerEmailCapabilityConfig>;
10193
}

apps/payments/next/.env

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,11 @@ CHURN_INTERVENTION_CONFIG__ENABLED=
100100
FREE_TRIAL_CONFIG__FIRESTORE_COLLECTION_NAME=freeTrials
101101

102102
# Free Access Program Client Config
103-
# NB: This needs to match config in payments-api
104-
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__COLLECTION_NAME=subplat-free-access-program
103+
# NB: Ideally this matches the config in payments-api
104+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__FIRESTORE_CACHE_COLLECTION_NAME=subplat-free-access-program-cache
105+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__MEM_CACHE_T_T_L=300 # 5 minutes
106+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__FIRESTORE_CACHE_TTL=1800 # 30 minutes
107+
FREE_ACCESS_PROGRAM_CLIENT_CONFIG__FIRESTORE_OFFLINE_CACHE_TTL=604800 # 7 days
105108

106109
# StatsD Config
107110
STATS_D_CONFIG__SAMPLE_RATE=

libs/free-access-program/project.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@
4444
"options": {
4545
"jestConfig": "libs/free-access-program/jest.config.ts"
4646
}
47-
},
48-
"reconcile-all": {
49-
"executor": "nx:run-commands",
50-
"options": {
51-
"command": "TS_NODE_PROJECT=tsconfig.base.json node -r ts-node/register/transpile-only -r tsconfig-paths/register libs/free-access-program/src/scripts/reconcile-all.ts"
52-
}
5347
}
5448
}
5549
}

libs/free-access-program/src/index.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
export * from './lib/auth-server-email-capability.client';
6-
export * from './lib/auth-server-email-capability.config';
75
export * from './lib/factories';
8-
// FreeAccessProgramReconcilerModule is consumed only by the standalone
9-
// reconcile-all script; intentionally not re-exported here so consumers of
10-
// the public lib don't pull in `nest-typed-config` (which ships as raw TS).
116
export * from './lib/free-access-program.client.config';
127
export * from './lib/free-access-program.manager';
13-
export * from './lib/free-access-program.notifier.service';
148
export * from './lib/free-access-program.projector';
159
export * from './lib/free-access-program.reconciler.service';
16-
export * from './lib/free-access-program.repository';
17-
export * from './lib/free-access-program.webhook.controller';
18-
export * from './lib/free-access-program.webhook.service';
1910
export * from './lib/free-access-program.webhook.types';
2011
export * from './lib/types';

libs/free-access-program/src/lib/auth-server-email-capability.client.ts

Lines changed: 0 additions & 68 deletions
This file was deleted.

libs/free-access-program/src/lib/auth-server-email-capability.config.ts

Lines changed: 0 additions & 36 deletions
This file was deleted.

libs/free-access-program/src/lib/factories.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
import { faker } from '@faker-js/faker';
6-
import { Timestamp } from '@google-cloud/firestore';
7-
import type { FirestoreFreeAccessProgramRecord } from './types';
6+
import type { FreeAccessRecord } from './types';
87

9-
export const FirestoreFreeAccessProgramRecordFactory = (
10-
override?: Partial<FirestoreFreeAccessProgramRecord>
11-
): FirestoreFreeAccessProgramRecord => ({
8+
export const FreeAccessRecordFactory = (
9+
override?: Partial<FreeAccessRecord>
10+
): FreeAccessRecord => ({
1211
entitlementId: faker.string.uuid(),
1312
email: faker.internet.email().toLowerCase(),
1413
capabilities: {
1514
[faker.string.alphanumeric({ length: 16 })]: [
1615
`cap-${faker.string.alphanumeric({ length: 8 })}`,
1716
],
1817
},
19-
expiresAt: Timestamp.fromDate(faker.date.future()),
18+
expiresAt: faker.date.future().getTime(),
2019
description: faker.lorem.sentence(),
2120
internalName: faker.company.name(),
22-
createdAt: Timestamp.fromDate(faker.date.recent()),
21+
createdAt: faker.date.recent().getTime(),
2322
...override,
2423
});

libs/free-access-program/src/lib/free-access-program-reconciler.module.ts

Lines changed: 0 additions & 93 deletions
This file was deleted.

0 commit comments

Comments
 (0)