(force = false)
| 214 | ); |
| 215 | |
| 216 | const refresh = (force = false): Effect.Effect<void> => |
| 217 | Effect.gen(function* () { |
| 218 | if (disabled) return; |
| 219 | if (!force) { |
| 220 | const fresh = yield* isFresh; |
| 221 | if (fresh) return; |
| 222 | } |
| 223 | const wrote = yield* withWriteLock( |
| 224 | Effect.gen(function* () { |
| 225 | if (!force) { |
| 226 | // Re-check freshness under the lock — another process may |
| 227 | // have refreshed between our outer check and acquisition. |
| 228 | const fresh = yield* isFresh; |
| 229 | if (fresh) return false; |
| 230 | } |
| 231 | yield* fetchAndWrite; |
| 232 | return true; |
| 233 | }), |
| 234 | ); |
| 235 | if (Option.isSome(wrote) && wrote.value) { |
| 236 | yield* invalidate; |
| 237 | } |
| 238 | }).pipe( |
| 239 | Effect.catchCause((cause) => |
| 240 | Effect.logDebug("IntegrationsRegistry.refresh failed").pipe( |
| 241 | Effect.annotateLogs("cause", cause), |
| 242 | ), |
| 243 | ), |
| 244 | Effect.withSpan("IntegrationsRegistry.refresh"), |
| 245 | ); |
| 246 | |
| 247 | const recurring = config.recurring ?? true; |
| 248 | if (!disabled && recurring) { |
no test coverage detected