(
self: M,
...[input, options]: [Machine.Input<M>] extends [void] ? [
input?: Machine.Input<M>,
options?: { readonly previousState?: Machine.State<M> }
] :
[
input: Machine.Input<M>,
options?: { readonly previousState?: Machine.State<M> }
]
)
| 468 | * @category runtime |
| 469 | */ |
| 470 | export const boot = < |
| 471 | M extends Machine.Any |
| 472 | >( |
| 473 | self: M, |
| 474 | ...[input, options]: [Machine.Input<M>] extends [void] ? [ |
| 475 | input?: Machine.Input<M>, |
| 476 | options?: { readonly previousState?: Machine.State<M> } |
| 477 | ] : |
| 478 | [ |
| 479 | input: Machine.Input<M>, |
| 480 | options?: { readonly previousState?: Machine.State<M> } |
| 481 | ] |
| 482 | ): Effect.Effect< |
| 483 | M extends { readonly [SerializableTypeId]: SerializableTypeId } ? SerializableActor<M> : Actor<M>, |
| 484 | never, |
| 485 | Machine.Context<M> | Scope.Scope |
| 486 | > => |
| 487 | Effect.gen(function*() { |
| 488 | const context = yield* Effect.context<Machine.Context<M>>() |
| 489 | const requests = yield* Queue.unbounded< |
| 490 | readonly [ |
| 491 | Procedure.TaggedRequest.Any, |
| 492 | Deferred.Deferred<any, any>, |
| 493 | Tracer.AnySpan | undefined, |
| 494 | addSpans: boolean |
| 495 | ] |
| 496 | >() |
| 497 | const pubsub = yield* Effect.acquireRelease( |
| 498 | PubSub.unbounded<Machine.State<M>>(), |
| 499 | PubSub.shutdown |
| 500 | ) |
| 501 | const latch = yield* Deferred.make<void>() |
| 502 | |
| 503 | let currentState: Machine.State<M> = undefined as any |
| 504 | let runState: { |
| 505 | readonly identifier: string |
| 506 | readonly publicTags: Set<string> |
| 507 | readonly decodeRequest: (u: unknown) => Effect.Effect<Machine.Public<M>, ParseResult.ParseError> |
| 508 | } = { |
| 509 | identifier: "Unknown", |
| 510 | publicTags: new Set<string>(), |
| 511 | decodeRequest: undefined as any |
| 512 | } |
| 513 | |
| 514 | const requestContext = <R extends Machine.Public<M>>(request: R) => |
| 515 | Effect.sync(() => { |
| 516 | const fiber = Option.getOrThrow(Fiber.getCurrentFiber()) |
| 517 | const fiberRefs = fiber.getFiberRefs() |
| 518 | const context = FiberRefs.getOrDefault(fiberRefs, FiberRef.currentContext) |
| 519 | |
| 520 | const deferred = Deferred.unsafeMake<Request.Success<R>, Request.Error<R>>(fiber.id()) |
| 521 | const span: Tracer.AnySpan | undefined = context.unsafeMap.get(Tracer.ParentSpan.key) |
| 522 | const addSpans = FiberRefs.getOrDefault(fiberRefs, currentTracingEnabled) |
| 523 | |
| 524 | return [request, deferred, span, addSpans] as const |
| 525 | }) |
| 526 | |
| 527 | const send = <R extends Machine.Public<M>>(request: R) => |
nothing calls this directly
no test coverage detected