Day 3 – Productive Procrastination
Tags: devlog, rust
Published: 2022-01-05 22:04:28

---
title: Day 3 – Productive Procrastination
published: true
date: 2022-01-05 21:00:00 UTC
tags: devlog,rust
series: Project A8N
canonical_url: https://www.jdno.dev/day-3-productive-procrastination/
---

![Day 3 – Productive Procrastination](https://images.unsplash.com/photo-1587654780291-39c9404d746b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=MnwxMTc3M3wwfDF8c2VhcmNofDN8fGxlZ298ZW58MHx8fHwxNjQxNDEyOTQz&ixlib=rb-1.2.1&q=80&w=2000)

After two days of mostly theoretical work, I felt like writing some code today. So I got my copy of the book [Zero to Production](https://www.zero2prod.com) and worked on the app's web server. As a result, the project is built with Rust now...

## Subscribing to Events from GitHub

I wrote about what a minimum viable product for this project would look like in [yesterday's post](https://dev.to/jdno/day-2-exploring-an-idea-21nl). One of the features that it needs is the ability to receive events from code hosting providers like GitHub. This feature has a simple and a complicated part.

The simple part is how platforms like GitHub deliver these events. Whenever something happens on GitHub, a webhook event is sent to any app that is subscribed to it. In the case of GitHub, this is done for (almost) literally [everything](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads). The webhook is sent to a pre-configured URL, which means the app needs a web server that can receive them.

The complicated part is figuring out what to do with the event. For this project, it means figuring out if any workflows need to run. This requires reading the user's configuration, which has been a topic of [yesterday's post](https://dev.to/jdno/day-2-exploring-an-idea-21nl) as well. Not much has changed since then, and how the configuration will look has yet to be decided.

So I decided to focus on the simple part that is clearly scoped for today.

## Zero to Production

Last year, I bought a copy of the book [Zero to Production](https://www.zero2prod.com) by Luca Palmieri. It describes how to build a production-grade backend server with [Rust](https://rust-lang.org). Back then I was working on a similar–albeit more limited–idea, and read through the first chapter as I was experimenting with the idea. I learned a lot from it, and always wanted to finish the book. As luck would have it, an update just dropped and I picked up the latest version and got started...

The book uses an iterative approach to introduce new topics. You start by setting up the web framework. Then you add integration tests, and after that a database. Each chapter builds on the previous one, and there is a strong focus on having something working after each step.

## +2,532 −1

After working through the first four chapters of the book, I reached a good stopping point for today. I have a web server now that can receive webhooks from GitHub. The server verifies the authenticity of the webhooks by checking their cryptographic signature. Everything is tested with integration tests. And instrumentation is in place to monitor the server once it gets deployed. A lot of code was added today.

The next step is putting the events in a queue so that they can be processed in the background. This requires figuring out what data is later needed to process the events. And it needs setting up a background job system.

When I worked as a [Ruby on Rails](https://rubyonrails.org/) developer in the past, I always had great experiences with [Sidekiq](https://sidekiq.org/). It was so good that it became second nature to throw everything that didn't need to be synchronous into a queue and process it in the background. Luckily, [Faktory](https://contribsys.com/faktory/) exists as a "polyglot version of Sidekiq" (don't @ me).

My goal for tomorrow is to integrate Faktory into the app, and throw incoming webhooks into a queue. A background worker can then pick them up and figure out what to do for the event. This last step will require figuring out how to store configuration, but that's a problem for another day...

Day 3 was fun, let's continue tomorrow!