Injecting dependencies for better Go

Perhaps the biggest habit I see from other languages (primarily JavaScript, Ruby and Python) is an attraction to a little bit of magic when it comes to construction of dependencies. Engineers tend to try and hide away the complexity of the initialisation of their application by putting bits such as connecting to a database within components of their application, rather than doing this within the main function. Here’s an example of that:...

August 16, 2021 · Noah Stride

Go: stop using sql.Open!

One of my biggest gripes in Go relates to the database/sql package. This roots from two concerns, which can be seen in the snippet below: import ( "database/sql" "time" _ "github.com/go-sql-driver/mysql" ) func connect() (*sql.DB, error){ db, err := sql.Open("mysql", "user:[email protected]/database?parseTime=true") if err != nil { return nil, err } return db, nil } Global registration is scary One of the first things in the file is the import statement, where we import the go-sql-driver/mysql package and mark it as unused with an underscore....

March 21, 2021 · Noah Stride

Running multiple services (HTTP/GRPC) with Docker Compose & Traefik

When developing a system with multiple services (whether that be microservices or a few monoliths), it can be handy to bring them all up locally to test your entire system. This is an almost perfect use-case for docker compose, especially if your apps are already dockerised (which they should be!) However, when some of your services expose themselves on the same port, this can cause quite the issue. Some choose to solve this by assigning a different port on the host to each container, but this can become unwieldy especially if each container exposes multiple different ports....

February 20, 2021 · Noah Stride

Beware Firebase Auth and GCP CICP

For over two years now, Google has offered a ‘Google-grade identity and access management’ platform under the Firebase brand as “Firebase Authentication” and under the parent GCP platform as ‘Cloud Identity for Customers and Partners (CICP)’. At first sight, they seem to be a fit solution for authentication, but are they all that they seem? I’ll start by at least addresssing the positives of the platform. They provide a relatively quick drop-in solution for authentication that ships supporting multiple popular providers, and that can be extended via SAML and OIDC to support practically anything....

February 8, 2021 · Noah Stride

Retaking the Helm: Kubernetes manifests as Go - WIP

This post is still work in progress :) A lot about Helm leaves me extremely dissatisfied, especially as manifests grow more complicated and I aim to reduce duplication. The templating language itself always leaves me thinking that there simply has to be a better way of doing this that doesn’t involve painstakingly adding {{ indent xyz }} and carefully stripping whitespace. It occurred to me that it must be possible to use the Kubernetes API types to directly define or generate these manifests from Go code, thus allowing us to use standard Go loops and conditionals or even including entire pre-written sections with the benefits of type-checking and editor auto-complete when working on more complex manifests....

September 13, 2020 · Noah Stride

RabbitMQ: Backoff is king

RabbitMQ is a fantastic piece of infrastructure for building event driven systems, but it’s far too easy to skip a key implementation detail early on (in haste, or ignorance) and end up creating extremely fragile systems. What I am referring to here is Message Redelivery and the need for some form of back-off. The worst-case scenario runs as follows: you have a series of queues that consume events that are published to your exchange....

September 7, 2020 · Noah Stride

Redis is great

It’s not often that a piece of tech really gets me excited, or at least excited enough to rant about it. Redis is one of the few that are lucky enough to have a place close to my heart (and it has for a few years), and it’s there for a many reasons but one part is key: Redis encapsulates doing something simple well Some might liken this to the Unix philosophy of ‘doing one thing well’, an adage that often gets on my nerves for the amount that it is thrown around, but they’d probably be right....

September 1, 2020 · Noah Stride

Scaling Firestore & lessons we learnt

Firestore (or GCP Datastore), as a concept, is pretty appealing: an (almost) infinitely scaleable, high availability NoSQL database. However, there’s quite a few things that will easily catch you out if you aren’t careful. This post will probably err more on the side of pointing out the negatives, since Firestore tend to sell you the positives pretty effectively themselves. Sharding Firestore shards documents between their instances based on the ID you’ve assigned each document....

August 16, 2020 · Noah Stride