(service: Context.Service<I, S>, layer: Layer.Layer<I, E>)
| 31 | } |
| 32 | |
| 33 | export function makeRuntime<I, S, E>(service: Context.Service<I, S>, layer: Layer.Layer<I, E>) { |
| 34 | let rt: ManagedRuntime.ManagedRuntime<I, E> | undefined |
| 35 | const getRuntime = () => (rt ??= ManagedRuntime.make(Layer.provideMerge(layer, Observability.layer), { memoMap })) |
| 36 | |
| 37 | return { |
| 38 | runSync: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runSync(attach(service.use(fn))), |
| 39 | runPromiseExit: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) => |
| 40 | getRuntime().runPromiseExit(attach(service.use(fn)), options), |
| 41 | runPromise: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>, options?: Effect.RunOptions) => |
| 42 | getRuntime().runPromise(attach(service.use(fn)), options), |
| 43 | runFork: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => getRuntime().runFork(attach(service.use(fn))), |
| 44 | runCallback: <A, Err>(fn: (svc: S) => Effect.Effect<A, Err, I>) => |
| 45 | getRuntime().runCallback(attach(service.use(fn))), |
| 46 | } |
| 47 | } |
no test coverage detected