Skip to content

Commit

Permalink
chore: up
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong committed Apr 23, 2024
1 parent 1fa5ec8 commit 0ad51eb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MConfig, DecoratorExecutorParamBase, DecoratorHandlerBase } from '@mwcp

import { ConfigKey, KmorePropagationConfig } from '##/lib/types.js'

import { decoratorExecutor, genDecoratorExecutorOptionsAsync } from './transactional.helper.js'
import { decoratorExecutorAsync, decoratorExecutorSync, genDecoratorExecutorOptionsAsync } from './transactional.helper.js'
import { DecoratorExecutorOptions, GenDecoratorExecutorOptionsExt } from './transactional.types.js'


Expand All @@ -20,7 +20,14 @@ export class DecoratorHandlerTransactional extends DecoratorHandlerBase {
}

override async executorAsync(options: DecoratorExecutorOptions) {
return decoratorExecutor(options)
return decoratorExecutorAsync(options)
}

/**
* @Caution Will not execute any method including database operations, just return the result
*/
override executorSync(options: DecoratorExecutorOptions) {
return decoratorExecutorSync(options)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function genDecoratorExecutorOptionsAsync<T extends object>(
}


export async function decoratorExecutor(options: DecoratorExecutorOptions): Promise<unknown> {
export async function decoratorExecutorAsync(options: DecoratorExecutorOptions): Promise<unknown> {
const {
instanceName,
mergedDecoratorParam,
Expand Down Expand Up @@ -140,3 +140,12 @@ async function processEx(options: ProcessExOptions): Promise<never> {
await trxStatusSvc.trxRollbackEntry(callerKey)
throw error
}



export function decoratorExecutorSync(options: DecoratorExecutorOptions): unknown {
const { method, methodArgs } = options
const resp = method(...methodArgs)
return resp
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe(fileShortPath(import.meta.url), () => {
describe('Should ignore @Cacheable combined with @Transactional', () => {
const prefix = apiPrefix.cache

it(apiRoute.get, async () => {
it.only(apiRoute.get, async () => {
const { httpRequest } = testConfig
const url = `${prefix}/${apiRoute.get}`

Expand Down

0 comments on commit 0ad51eb

Please sign in to comment.