WGD 2022-05-20

Fri, May 20, 2022 2-minute read

WGD 2022-05-20

Still working on Mudmap’s switch from single user accounts to multiple accounts per organisation.


I’m making a lot of progress on the transition from the one user one account model. I’ve had to create extra tables, migrate users and devices between them whilst ensuring backwards compatibility. I think the changes to the database models are done for this section of changes - permissions will come next.

I learned how to write Postgres subqueries this week and it’s pretty cool seeing a complex query execute repeatedly without issue.

User and organisation (what I’m calling accounts) data is stored in the database but a couple of items are being used in context.Values. Doing this prevents Mudmap from having to do queries for user or organisation data when accessing other related data. I understand that it is a slight anti-pattern but I feel it’s actually a good use case for it. Using context also allows for storing certain keys in the authentication token. Again, it saves extra queries.

I’ve been using go-resty for making and receiving HTTP requests inside Mudmap. In the past I’ve written HTTP clients using just the standard lib but resty provides a few things I need almost out of the box. Namely, retries and interceptors. When a token expires, resty is configured to automatically re-authenticate by sending a POST to the auth backend. I could write that myself but I’m running a business and don’t have time for that!

Also got to play with some Go Mutex’s this week too. Have not really had a need to implement any until now, and it’s pretty easy. Three lines of code will get you pretty far.

// contrived example
var mu sync.Mutex
defer mu.Unlock


Had some huge wins at work this week. Our team got a lot of kudo’s for the work we’ve been putting it too. No rest though, straight from one fire to the next. So far, I’ve worked on Django, Angular and Android this week alone. Its enough to scatter a man’s brain.