# ago **Repository Path**: mirrors_couchbaselabs/ago ## Basic Information - **Project Name**: ago - **Description**: snapshots and rewinding on top of ClojureScript core.async - **Primary Language**: Unknown - **License**: EPL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-08 - **Last Updated**: 2026-05-23 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # ago - [![Build Status](https://travis-ci.org/steveyen/ago.png?branch=master)](https://travis-ci.org/steveyen/ago) A time travel library for clojurescript core.async The "ago" library provides a limited form of time travel (snapshots and restores) on top of clojurescript core.async. ## Rationale The ago library came about because I was using core.async to handle concurrent tasks. In particular, I was trying to simulate some concurrent clients, servers and network protocols of a "fake" distributed system, and core.async was a good building block to model all the concurrent activity. (I used go routines for the client & server "processes" and used channels to hook them up together.) By using clojurescript core.async, too, I could run my simulated "distrbuted system" as a 100% client-side, single page application and get a quick web browser GUI and visualization of everything happening in the simulation. But, it wasn't clear how to "rewind the world" back to a previous simulation state so that I could play "what-if" games with the simulated world. That is, I wanted to... * snapshot all the inflight go routines, channels, messages, timeouts and all their inherent state; * take multiple snapshots over time; * and finally, later restore the world to some previous snapshot and restart the world from exactly that point in time. The ago library is meant to provide that snapshot and restore ability, so that one can have "TiVo for clojurescript core.async". Or, if you like synonyms... ago lets you go backwards in your go routines to sometime ago ## How To Use ago ### require First, you'll need to require the relevant clojurescript macros and functions, like... (ns my-application (:require-macros [ago.macros :refer [ago]]) (:require [cljs.core.async :refer [close! ! alts! put! take!]] [ago.core :refer [make-ago-world ago-chan ago-timeout ago-snapshot ago-restore]])) ### API: make-ago-world The make-ago-world API function creates a world-handle, which is an atom where the ago library tracks everything about a snapshot'able world. (make-ago-world app-data) ; returns a world-handle. You must also supply some opaque app-data (use that app-data for whatever you want) that will be associated with the world-handle. This can also be nil... (make-ago-world nil) ### API: ago The ago library provides an alternative or twin set of API's which wrap around the main creation API's of core.async. These mirrored API's usually have an additional first parameter of a world-handle. For example, instead of... (go ...) ...use... (ago world-handle ...) ; returns a chan ### API: ago-chan Instead of (chan), use... (ago-chan world-handle) ; returns a chan ### Example So, you would create "ago channels" and "ago routines", passing in a world-handle. For example, instead of writing... (let [ch1 (chan)] (go (>! ch1 "hello world")) (go ["I received" (! ch1 "hello world")) (ago world-handle ["I received" (