Issue 12: First Ergo Run, Better Scripts
Missed last week due to sick kids, but things are back to normal this week, so let’s go!
What I’m Working On
The big news is that Ergo works and the first task has run: triggering youtube-dl from an HTTP request! It’s a simple task running on a complex framework, but I now have bunch of core features to enable more involved tasks:
- Job queues
- State machines
- Dataflow linking inputs to actions
- Role-based auth
With this big coding sprint done, I’ll hopefully get back into writing some blog posts again, and the implementation of these features will make for some good topics to write about.
Up next for the project: Slack/Discord notifications when things happen, HTTP request actions that tasks can run, much more testing, and delving into executing Javascript within state machines!
Recommended Reading and Videos
zx
Bash scripts are fine for simple tasks, but as the script grows in complexity it can become a real hassle. Argument parsing, string handling, interactive prompts, and more are much harder than they really should be.
These problems are often alleviated by writing using Node, Python, Rust, etc., but they have their own, different set of things that are hard to do. Running programs and capturing the output, for example, is easy to do in Bash, and while not exactly difficult in other languages, is not exactly a one-liner.
zx seeks to bridge this gap. It runs a Node.js environment, but with some extra functions to make it easier to use. First, running external processes in a bash environment can be done with a tagged template string:
let output = await $`ls | grep json`; // Easily run in parallel! await Promise.all([ $`scp file.json server1`, $`scp file.json server2`, $`scp file.json server3` ]);
zx also provides functions such as question
for interactive prompts, and built-in access to fetch
, chalk
, and more. This is a very new project, less than two weeks old, so there are sill some lacking features here and there, but I can’t wait to see what comes next!
Bruce Momjian’s Postgres Blog
Bruce is a long-time committer to PostgreSQL, and he frequently writes blogs about various topics. These range from tips and tricks to internal implementation details, and most of the articles are pretty short, so it’s well worth subscribing.
Zero to Production in Rust
This book-in-progress by Luca Palmieri has been very helpful in covering web server programming in Rust. It covers the basics, but also recommends certain paradigms and practices in writing the code, which is where I’ve found a lot of the value. Luca’s blogs contains a lot of the book content as well if you want to sample it before buying. Definitely worth a read.
If you enjoyed this, I’d love if you share it with a friend (sign up here) or just reply to this email with your thoughts. Thanks for reading!