All Projects → walmartlabs → Active Status

walmartlabs / Active Status

Licence: apache-2.0
Present status of mulitple 'jobs' in a command line tool, using terminal capability codes

Programming Languages

clojure
4091 projects

Labels

Projects that are alternatives of or similar to Active Status

Tedis
redis client with typescript and esnext for nodejs
Stars: ✭ 109 (-9.17%)
Mutual labels:  async
Jdeferred
Java Deferred/Promise library similar to JQuery.
Stars: ✭ 1,483 (+1135.83%)
Mutual labels:  async
Popol
Minimal non-blocking I/O for Rust
Stars: ✭ 118 (-1.67%)
Mutual labels:  async
Babel Plugin Mobx Deep Action
Reduces `action` and `runInAction` boilerplates
Stars: ✭ 110 (-8.33%)
Mutual labels:  async
Aiormq
Pure python AMQP 0.9.1 asynchronous client library
Stars: ✭ 112 (-6.67%)
Mutual labels:  async
Drone
CLI utility for Drone, an Embedded Operating System.
Stars: ✭ 114 (-5%)
Mutual labels:  async
Micro
Asynchronous HTTP microservices
Stars: ✭ 9,987 (+8222.5%)
Mutual labels:  async
Process
An async process dispatcher for Amp.
Stars: ✭ 119 (-0.83%)
Mutual labels:  async
Async Backplane
Simple, Erlang-inspired fault-tolerance framework for Rust Futures.
Stars: ✭ 113 (-5.83%)
Mutual labels:  async
Hooks
Async middleware for JavaScript and TypeScript
Stars: ✭ 117 (-2.5%)
Mutual labels:  async
Ws Machine
WS-Machine is a websocket finite state machine for client websocket connections (Go)
Stars: ✭ 110 (-8.33%)
Mutual labels:  async
Aww
Async Iterables Interfaces for Web Workers
Stars: ✭ 113 (-5.83%)
Mutual labels:  async
Nuclei
Proactive IO & Runtime system
Stars: ✭ 113 (-5.83%)
Mutual labels:  async
Aiometer
A Python concurrency scheduling library, compatible with asyncio and trio.
Stars: ✭ 110 (-8.33%)
Mutual labels:  async
Advanced Vertx Guide
A gentle guide for advanced Vert.x users
Stars: ✭ 118 (-1.67%)
Mutual labels:  async
Snug
Write reusable web API interactions
Stars: ✭ 108 (-10%)
Mutual labels:  async
Madelineproto
Async PHP client/server API for the telegram MTProto protocol
Stars: ✭ 1,776 (+1380%)
Mutual labels:  async
Sketal
Бот для ВКонтакте. Беседы / группы / развлечения.
Stars: ✭ 119 (-0.83%)
Mutual labels:  async
Bach
Compose your async functions with elegance.
Stars: ✭ 117 (-2.5%)
Mutual labels:  async
Cassandra Sharp
high performance .NET driver for Apache Cassandra
Stars: ✭ 114 (-5%)
Mutual labels:  async

walmartlabs/active-status

Clojars Project

An update-in-place status board for asynchronous processes inside your Clojure command line application.

You write in Clojure and use core.async.
Traditional logging is fine for traditional servers, but what if you are writing a command line application? And what if that application is doing things asynchronously? What kind of output do you want?

That's what active-status is for; it provides a status board ... console output that updates in-place. A simple way to let asynchronous jobs report their status and progress.

batman demo

Here's a more realistic example, from db-migrate-example:

database migration demo

API Documentation

API Documentation

Example Code

(require '[com.walmartlabs.active-status :as as]
         '[clojure.core.async :refer [close! >!!]])

(defn process-files [board-ch files]
  (let [job-ch (as/add-job board-ch)]
      (>!! job-ch (as/start-progress (count files)))
      (doseq [f files]
        (>!! job-ch (str "Processing: " f))
        (process-single-file f)
        (>!! job-ch (as/progress-tick)))
      (close! job-ch)))
      
 (def board-ch (as/console-status-board))
             
 (process-files board-ch (file-seq "process-dir"))                   

Of course, this is a simple example. You are more likely to have multiple jobs running at any one time, of different types, implemented as core.async go blocks, rather than traditional single-threaded code in this example.

Limitations

tput

Under the covers, active-status makes use of the tput command line tool. This provides the terminal capabilities (special strings) that allow for moving the cursor around the screen. It also expects that your console respects standard ANSI codes for formatting (bold and colored text).

This largely eliminates the use of the library on Windows platforms.

In addition, the library uses italic font for completed jobs ... but even on OS X, Terminal.app does not support italics out of the box; this post explains how to setup italics.

iTerm2 version 3 does support italics. It's free and awesome, you should be using this.

Terminal width

The library currently doesn't know about the width of the terminal; it will output any job summary text provided, and may inadvertently wrap the output.

Other output

The library has no way of determining if some other part of the application is writing to *out* or *err*. Any such output will either move the cursor or scroll the screen; the library uses relative cursor motion when updating a job's line in the status board, so either of these cases will cause job output to be printed on the wrong lines (lower than expected). This is compounded by the fact that job lines are only updated when the underlying data is changed (by sending an update to the job's channel).

Starting in 0.1.8, the with-output-redirected macro can usually, but not always, prevent unwanted output from interfering with the status board.

TL;DR: Don't write any output while the status board is running.

Compatibility

It currently renders quite well in iTerm.

In Terminal.app, the default terminfo is 'ansi'; the library works correctly only if this is changed to 'xterm' (or some variant).

IntelliJ Terminal (IntelliJ 15, OS X) seems to work fine.

Cursive REPL (Intellij 15, OS X) is currently quite broken, alas. But, then again, REPL oriented development and the status tracker are not a good mix (see the "other output" section above).

Component

The namespace com.walmartlabs.active-status.component defines a component that may be used within a overall component system, which uses configuration to decide whether to instantiate the console status board, or the minimal status board.

See com.stuartsierra/component and Schematic.

Execution

active-status is intended for long running jobs. Typically, the deployment model is an Uberjar. For best execution, use nohup and redirect input and output:

java -jar xxx-standalone.jar ... > console.out 2> console.err < /dev/null & tail -f console.out

This will start the application running, and it will continue to completion, even after a logout. Output is sent to a file, which can be tailed to see current status.

Future Directions

More options than the console score board are expected; these might include a pop-up Swing frame, or a client/server approach (with a server acting as the score board, and providing a web user interface).

A ClojureScript variant, especially one that could work in Node, would be valuable.


walmartlabs/active-status is released under the terms of the Apache Software License 2.0.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].