free-agent
Safe HaskellNone
LanguageGHC2024

Free.Agent.Pipeline

Description

Inspectable shard pipelines over addressed posts.

A Pipeline is a reified sequence of pure list-transformer stages. Each stage consumes a stream of a and produces a stream of b; the whole pipeline folds into a single pure function and is then wrapped as a stateful Shard.

Synopsis

Documentation

data Pipeline a b where Source #

A pipeline stage or composition of stages.

Constructors

Filter :: forall a. (a -> Bool) -> Pipeline a a

Keep only inputs that satisfy the predicate.

Map :: forall a b. (a -> b) -> Pipeline a b

Transform each input.

Route :: forall a b. (a -> [b]) -> Pipeline a b

Expand each input into zero or more outputs.

Compose :: forall b1 b a. Pipeline b1 b -> Pipeline a b1 -> Pipeline a b

Sequence two pipelines.

Instances

Instances details
Category Pipeline Source #

Pipelines form a category: id is Map id; composition is Compose.

Instance details

Defined in Free.Agent.Pipeline

Methods

id :: Pipeline a a #

(.) :: Pipeline b c -> Pipeline a b -> Pipeline a c #

runPipeline :: Pipeline a b -> [a] -> [b] Source #

Fold a pipeline into a pure list function.

pipelineShard :: Pipeline a b -> Poles (Body (,) [a] (K IO)) [a] [b] Source #

Run a pipeline as a closed stateful shard.

The state holds the pending input batch. Commit replaces it; emit applies the pipeline and clears the buffer.

filterP :: (a -> Bool) -> Pipeline a a Source #

Keep only inputs that satisfy the predicate.

mapP :: (a -> b) -> Pipeline a b Source #

Transform each input.

routeP :: (a -> [b]) -> Pipeline a b Source #

Expand each input into zero or more outputs.

routeTo :: Name -> Pipeline (Post Text) (Post Text) Source #

Route every post to a single recipient.

routeBy :: (Post Text -> [Name]) -> Pipeline (Post Text) (Post Text) Source #

Route posts using a function from the post to a recipient list.

broadcast :: [Name] -> Pipeline (Post Text) (Post Text) Source #

Broadcast every post to a list of recipients.

forName :: Name -> Pipeline (Post Text) (Post Text) Source #

Keep posts addressed to name (via deliversTo).

fromName :: Name -> Pipeline (Post Text) (Post Text) Source #

Keep posts whose sender is name.