• Stars
    star
    119
  • Rank 297,930 (Top 6 %)
  • Language
    Clojure
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Present status of mulitple 'jobs' in a command line tool, using terminal capability codes

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.

More Repositories

1

lacinia

GraphQL implementation in pure Clojure
Clojure
1,821
star
2

thorax

Strengthening your Backbone
JavaScript
1,322
star
3

react-ssr-optimization

React.js server-side rendering optimization with component memoization and templatization
JavaScript
822
star
4

electrode

Electrode - Application Platform on React/Node.js powering Walmart.com
449
star
5

little-loader

A lightweight, IE8+ JavaScript loader
JavaScript
370
star
6

json-to-simple-graphql-schema

Transforms JSON input into a GraphQL schema
JavaScript
283
star
7

eslint-config-defaults

A composable set of ESLint defaults
JavaScript
228
star
8

lumbar

Modular javascript build tool
JavaScript
226
star
9

concord

Concord - workflow orchestration and continuous deployment management
Java
211
star
10

datascope

Visualization of Clojure data structures using Graphviz
Clojure
207
star
11

lacinia-pedestal

Expose Lacinia GraphQL as Pedestal endpoints
Clojure
200
star
12

bigben

BigBen - a generic, multi-tenant, time-based event scheduler and cron scheduling framework
Kotlin
196
star
13

kubeman

The Hero that Kubernetes deserves
TypeScript
164
star
14

system-viz

Graphviz visualization of a component system
Clojure
161
star
15

react-native-orientation-listener

A react-native library for obtaining current device orientation
Java
151
star
16

thorax-seed

JavaScript
131
star
17

vizdeps

Visualize Leiningen dependencies using Graphviz
Clojure
131
star
18

mupd8

Muppet
Scala
126
star
19

schematic

Combine configuration with building a Component system
Clojure
104
star
20

easy-fix

easy-fix: run integration tests like unit tests
JavaScript
101
star
21

dyn-edn

Dynamic properties in EDN content
Clojure
96
star
22

fruit-loops

Server-side jQuery API renderer.
JavaScript
88
star
23

generator-thorax

Thorax yeoman generator
JavaScript
87
star
24

walmart-cla

Walmart Contributor License Agreement Information
85
star
25

react-native-cropping

Cropping components for react-native
JavaScript
68
star
26

gozer

Open source library to parse various X12 file formats for retail/supply chain
Java
66
star
27

curved-carousel

An infinitely scrolling carousel with configurable curvature
JavaScript
64
star
28

walmart-api

API wrapper for the public Walmart Labs API
JavaScript
61
star
29

cookie-cutter

An opinionated micro-services framework for TypeScript
TypeScript
58
star
30

mock-server

SPA application debug proxy server
JavaScript
57
star
31

test-reporting

Tiny library to assist with reporting some context when a test fails
Clojure
53
star
32

container-query

A responsive layout helper based on the width of the container
JavaScript
52
star
33

eslint-config-walmart

A set of default eslint configurations, Walmart Labs style.
JavaScript
49
star
34

react-native-platform-visible

A very simple component visibility switch based on Platform
JavaScript
49
star
35

clojure-game-geek

Example source code for the Lacinia tutorial
Clojure
47
star
36

generator-release

Yeoman generator for handling Bower/NPM releases.
JavaScript
45
star
37

babel-plugin-react-cssmoduleify

Babel plugin to transform traditional React element classNames to CSS Modules
JavaScript
45
star
38

costanza

Frontend error tracking toolkit: Own your own domain
JavaScript
36
star
39

zFAM

z/OS-based File Access Manager
Assembly
36
star
40

nightcall

Automated Enumeration Script for Pentesting
Python
33
star
41

cond-let

A useful merge of cond and let
Clojure
30
star
42

static

JavaScript
26
star
43

bolt

[DEPRECATED] an opinionated meta task runner for components.
JavaScript
24
star
44

shared-deps

Leiningen plugin to allow sub-modules to more easily share common dependencies
Clojure
24
star
45

ridicule

Mocking everything
JavaScript
22
star
46

linearroad

Walmart version of the Linear Road streaming benchmark.
Java
22
star
47

backbone-historytracker

Backbone plugin for navigation direction tracking
JavaScript
22
star
48

zECS

z/OS-based Enterprise Cache Service
COBOL
21
star
49

pulsar

Text-based dashboard for Elixir CLIs
Elixir
20
star
50

react-native-image-progressbar

An image based progress bar
JavaScript
20
star
51

zUID

z/OS-based Unique Identifier generator
Assembly
17
star
52

layout

A simple responsive layout helper
CSS
17
star
53

showcase-template

A starter template for a showcase of React components
CSS
16
star
54

anomaly-detection-walmart

Python
15
star
55

grunt-release-component

Grunt release helper for bower components
JavaScript
15
star
56

partnerapi_sdk_dotnet

Walmart Partner API SDK for .NET
C#
14
star
57

concord-website

Documentation website source code for Concord
JavaScript
14
star
58

circus

External Webpack Component Plugin
JavaScript
13
star
59

concord-plugins

Java
12
star
60

strati-functional

A lightweight collection of functional classes used to complement core Java.
Java
12
star
61

thorax-boilerplate

A boilerplate project for Thoroax
JavaScript
11
star
62

nocktor

nocktor - your nock doctor
JavaScript
11
star
63

LinearGenerator

Reworked data generator for LinearRoad streaming benchmark that no longer needs mitsim or any database.
Java
9
star
64

getting-started

How to get started with the WalmartLabs API and tooling
9
star
65

json-patchwork

JavaScript
9
star
66

object-diff

A Go library implementing object wise diff and patch.
Go
8
star
67

small-world-graph

Graphing as in Data
C++
8
star
68

chai-shallowly

A chai assertion plugin for enzyme.
JavaScript
8
star
69

typeahead.js-legacy

typeahead.js is a fast and fully-featured autocomplete library
JavaScript
8
star
70

child-pool

child_process pool implementation
JavaScript
7
star
71

thorax-todos

JavaScript
6
star
72

hula-hoop

Server-side rendering components for Thorax + Hapi stacks.
JavaScript
6
star
73

apache-http-client

A Clojure ring compatible http interface for Apache HttpClient
Clojure
5
star
74

lumbar-loader

JavaScript
5
star
75

krabby

JavaScript
4
star
76

js-conceptualizer

JS Conceptualizer is a bit of client-side Javascript that parses out concepts, particularly proper nouns, from HTML on a web page.
JavaScript
4
star
77

babel-plugin-i18n-id-hashing

Namespace the ID of React-Intl keys
JavaScript
4
star
78

express-example

A crazy simple example of using the Walmart API with express
JavaScript
4
star
79

wml-coding-std

A module for keeping consistent JS coding standards at WML
JavaScript
3
star
80

nativedriver

native driver for UI automation
Objective-C
3
star
81

was

Go
3
star
82

hapi-example

A crazy simple example of using the Walmart API with hapi
JavaScript
3
star
83

lumbar-long-expires

Long expires cache buster plugin for Lumbar
JavaScript
3
star
84

component-scan

A component scanner for React
JavaScript
3
star
85

scanomatic-server

Scan-O-Matic Node Server
JavaScript
3
star
86

hadoop-openstack-swifta

hadoop-openstack-swifta
Java
3
star
87

thorax-rails

Ruby
3
star
88

SDJSBridge

Native/Hybrid Javascript Bridge
Objective-C
2
star
89

cordova-starter-kit

A starter kit for using Cordova and the Walmart API
JavaScript
2
star
90

priorityY

Priority Based Connected Components
Python
2
star
91

bolt-standard-flux

electrode bolt standard configs and tasks for flux architecture.
JavaScript
1
star
92

bolt-cli

[DEPRECATED] bolt command line interface.
JavaScript
1
star
93

github-util

Github utility methods.
JavaScript
1
star
94

circus-stylus

Stylus linker for Circus components
JavaScript
1
star
95

apidocs

HTML
1
star
96

lumbar-tester

Unit testing plugin for Lumbar
JavaScript
1
star
97

SDUserActivity

An simplified interface for NSUserActivity for apps that want to participate in handoff.
Objective-C
1
star
98

walmartlabs.github.io

Helper to redirect to code.walmartlabs.com
HTML
1
star
99

BurpSuiteDynamicSessionTracker

BurpSuite extension for tracking and manipulating dynamic session cookies
Java
1
star
100

phoenix-build

Common build libraries for Phoenix projects
JavaScript
1
star