Skuld.PageMachine.Spindle (skuld_concurrency v0.41.0)

View Source

Named 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

env_key()

Environment state key for %Spindle.Mappings{}.

fork(key, computation)

Fork a named spindle as a FiberPool fiber.

Returns a Handle that can be used with FiberPool.await!/1.

with_handler(computation)

Install the Spindle handler. Must be installed outside FiberPool.with_handler/1 in the handler chain.