-
Notifications
You must be signed in to change notification settings - Fork 229
feat(payments-next): use LoggerService within TypeCachable decorators #20215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,8 @@ | |
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
|
||
| import { Inject, Injectable } from '@nestjs/common'; | ||
| import { Inject, Injectable, Logger } from '@nestjs/common'; | ||
| import type { LoggerService } from '@nestjs/common'; | ||
| import { Stripe } from 'stripe'; | ||
| import { Cacheable } from '@type-cacheable/core'; | ||
|
|
||
|
|
@@ -52,7 +53,8 @@ export class StripeClient { | |
| private readonly stripe: Stripe; | ||
| constructor( | ||
| private stripeConfig: StripeConfig, | ||
| @Inject(StatsDService) public statsd: StatsD | ||
| @Inject(StatsDService) public statsd: StatsD, | ||
| @Inject(Logger) public log: LoggerService | ||
| ) { | ||
| this.stripe = new Stripe( | ||
| // 'api_key_placeholder' is currently needed during build time | ||
|
|
@@ -139,8 +141,8 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('subscriptionsList', undefined, args[0]), | ||
| strategy: new CacheFirstStrategy(), | ||
| client: new AsyncLocalStorageAdapter(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| client: (_: any, context: StripeClient) => new AsyncLocalStorageAdapter(false, context.log), | ||
|
Comment on lines
+144
to
+145
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a good idea. Typecasting to |
||
| }) | ||
| @CaptureTimingWithStatsD() | ||
| async subscriptionsList(params?: Stripe.SubscriptionListParams) { | ||
|
|
@@ -194,8 +196,8 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('subscriptionsRetrieve', args[0], args[1]), | ||
| strategy: new CacheFirstStrategy(), | ||
| client: new AsyncLocalStorageAdapter(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| client: (_: any, context: StripeClient) => new AsyncLocalStorageAdapter(false, context.log), | ||
| }) | ||
| @CaptureTimingWithStatsD() | ||
| async subscriptionsRetrieve( | ||
|
|
@@ -315,8 +317,8 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('paymentMethodsRetrieve', args[0], args[1]), | ||
| strategy: new CacheFirstStrategy(), | ||
| client: new AsyncLocalStorageAdapter(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| client: (_: any, context: StripeClient) => new AsyncLocalStorageAdapter(false, context.log), | ||
| }) | ||
| @CaptureTimingWithStatsD() | ||
| async paymentMethodRetrieve( | ||
|
|
@@ -343,7 +345,7 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('pricesRetrieve', args[0], args[1]), | ||
| strategy: new CacheFirstStrategy(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| ttlSeconds: 600, | ||
| client: new MemoryAdapter(), | ||
| }) | ||
|
|
@@ -359,7 +361,7 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('productsRetrieve', args[0], args[1]), | ||
| strategy: new CacheFirstStrategy(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| ttlSeconds: 600, | ||
| client: new MemoryAdapter(), | ||
| }) | ||
|
|
@@ -375,7 +377,7 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('promotionCodesList', undefined, args[0]), | ||
| strategy: new CacheFirstStrategy(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| ttlSeconds: 600, | ||
| client: new MemoryAdapter(), | ||
| }) | ||
|
|
@@ -391,7 +393,7 @@ export class StripeClient { | |
| @Cacheable({ | ||
| cacheKey: (args: any) => | ||
| cacheKeyForClient('promotionCodesRetrieve', args[0], args[1]), | ||
| strategy: new CacheFirstStrategy(), | ||
| strategy: (_: any, context: StripeClient) => new CacheFirstStrategy(undefined, undefined, context.log), | ||
| ttlSeconds: 600, | ||
| client: new MemoryAdapter(), | ||
| }) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unnecessary optimization for a legacy mapping service, and no performance hit has been seen as a result of the prior pattern.