Skip to main content
An actor often needs to know when something changes: a price, a piece of news, an event somewhere else. It could fetch that itself on a schedule, and pay a runner each time. A data feed is the cheaper way. Its owner keeps publishing messages to it, the network holds the recent ones, and any actor can read them. A feed never calls your actor. The actor keeps its own place in the feed and catches up when it’s asked to, so one slow reader can’t hold anyone else up.

Follow a feed

Mark a handler with @on_stream, and name the feed. The guard picks out the messages you care about, here prices above 120.00:
The feed scales its numbers, so 12000 at scale 2 means 120.00.

Catch up

Every actor with an @on_stream handler has a public read_streams handler. Each call reads one page of each feed from where the actor left off, runs your handler on the messages that match, and saves its place, all in one transaction. If your handler fails, nothing changes, and the next call tries again.
Output
Anyone can make that call, and whoever calls it pays. Its result says if there’s more to read. A feed keeps only its recent messages, so an actor that falls too far behind has to skip ahead.

Find or publish a feed

The General Store lists feeds you can use. To publish your own, see cowboy watchtower.

Next