Skuld.PageMachine.Spindle (skuld_concurrency v0.42.0)
View SourceNamed concurrent sub-computations (spindles) that run as fibers within a FiberPool. Each spindle is identified by an atom key and communicates results through auto-tagged yields.
Usage
use Skuld.Syntax
comp do
checkout <- Spindle.fork(:checkout, MyApp.CheckoutFlow.flow(product))
# Main spindle continues...
filters <- Yield.yield(:search)
{:ok, results} <- MyApp.ProductCatalog.search(filters)
Yield.yield({:results, results})
end
|> Spindle.with_handler()
|> FiberYield.with_handler()
|> FiberPool.with_handler()
|> Comp.run()
Summary
Functions
Environment state key for %Spindle.Mappings{}.
Fork a named spindle as a FiberPool fiber.
Install the Spindle handler. Must be installed outside FiberPool.with_handler/1
in the handler chain.
Functions
Environment state key for %Spindle.Mappings{}.
@spec fork(atom(), Skuld.Comp.Types.computation()) :: Skuld.Comp.Types.computation()
Fork a named spindle as a FiberPool fiber.
Returns a Handle that can be used with FiberPool.await!/1.
@spec with_handler(Skuld.Comp.Types.computation()) :: Skuld.Comp.Types.computation()
Install the Spindle handler. Must be installed outside FiberPool.with_handler/1
in the handler chain.