(
...rest:
| [callback: (isolationScope: Scope) => T]
| [isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T]
)
| 118 | * Either creates a new active isolation scope, or sets the given isolation scope as active scope in the given callback. |
| 119 | */ |
| 120 | export function withIsolationScope<T>( |
| 121 | ...rest: |
| 122 | | [callback: (isolationScope: Scope) => T] |
| 123 | | [isolationScope: Scope | undefined, callback: (isolationScope: Scope) => T] |
| 124 | ): T { |
| 125 | const carrier = getMainCarrier(); |
| 126 | const acs = getAsyncContextStrategy(carrier); |
| 127 | |
| 128 | // If a scope is defined, we want to make this the active scope instead of the default one |
| 129 | if (rest.length === 2) { |
| 130 | const [isolationScope, callback] = rest; |
| 131 | |
| 132 | if (!isolationScope) { |
| 133 | return acs.withIsolationScope(callback); |
| 134 | } |
| 135 | |
| 136 | return acs.withSetIsolationScope(isolationScope, callback); |
| 137 | } |
| 138 | |
| 139 | return acs.withIsolationScope(rest[0]); |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Get the currently active client. |
no test coverage detected