Async Classes¶
AsyncCombinator¶
Base class for async combinators. Integrates with use_tracing().
Methods:
async run(ctx: T) -> tuple[bool, T]-- Execute the combinatorif_else(then, else_) -> AsyncCombinator[T]-- Conditional branching__and__,__or__,__invert__,__rshift__-- Operator overloading
AsyncPredicate¶
Async predicate that checks a condition without modifying context.
Constructor:
Example:
AsyncPredicateFactory¶
Factory for parameterized async predicates. Created by @async_rule_args.
Example:
@async_rule_args
async def has_role(user, role):
return await db.check_role(user.id, role)
check = has_role("admin") # AsyncPredicate[User]
AsyncTransform¶
Async transform that modifies context.
Attributes:
last_error: Exception | None-- The last exception (not concurrency-safe)
Methods:
async run(ctx: T) -> tuple[bool, T]-- Execute the transformasync run_with_error(ctx: T) -> tuple[bool, T, Exception | None]-- Concurrency-safe error access
Example:
@async_pipe
async def load_profile(user):
user.profile = await api.get_profile(user.id)
return user
ok, result, error = await load_profile.run_with_error(user)
AsyncTransformFactory¶
Factory for parameterized async transforms. Created by @async_pipe_args.
Example: