It's been a while since my last post as I've been wrangling silica-laced storms in the Sahara and preparing for spaceflight in Star City. Not buying it? Okay fine! I've just been at home mostly working on Android and Angular things. Sometimes I just seek that type of mental cathartic escape. Oh, and I've fallen in love with Go!

So we'll be making our very own gRPC Go server on a Raspberry Pi with balenaOS.

(0) The Components

Go

If you haven't heard of the Go programming language before, then don't worry, we're sending some help to get you out of that era!

In a nutshell, Go is a highly readable, über fast programming language conceived in 2009 by engineers at Google. It has baked in concurrency in the form of goroutines which are functions that run concurrently with other functions or methods and can be thought of as a light weight version of a thread with a fraction of the cost.

One of the premises of the language was to be a modern and highly productive implementation of Communicating Sequential Processes (CSP), outlined by C. Hoare in 1978.

gRPC

I take it you know REST, which is ubiquitous across the web. REST is usually implemented with JSON payloads over HTTP. These are textual representations of resources.

gRPC or gRPC Remote Procedure Calls or (gRPC  Remote Procedure Calls) Remote Procedure Calls or ((gRPC Remote Procedure Calls) Remote Procedure Calls) Remote Procedure Calls ... ¯\_(ツ)_/¯ ... is a modern and high performance RPC framework that can run in any environment. gRPC can use JSON  but in practice Google's Protobuf tends to be used. It's a binary format so it makes communication a lot more efficient and faster.

You can think that while REST has a resource-centric view of things, RPC has a command-centric view. REST has one set of ubiquitous methods, called verbs. These have taken on the form of HTTP methods such as GET, POST, PATCH in most cases. RPC has custom and unique sets of methods.

balenaOS and balenaCloud

From the balena.io website:

"Balena is a complete set of tools for building, deploying, and managing fleets of connected Linux devices. "

balenaOS allows you to run containers on ARM based Linux devices such as the Raspberry Pi. Their cloud platform is free for up to 10 devices and lets you push updates to applications running in containers on devices. They also offer an open source version that you can set up on your own machine.

Raspberry Pi

A credit card sized ARM-based computer.

Raspberry Pi 3 Model B+

Go get one!

In this project I used my Raspberry Pi 3 Model B, but any model compatible with balenaOS will work just fine.

(1) Setup

balenaCloud Account

You'll first need to go and sign up for a new balenaCloud account at balena.io. It's completely free for your first ten devices with no functionality restrictions or credit card required.

Then go ahead and create a new application from the dashboard:

Create application dialog on balenaCloud.

Make sure to select the correct device type. In my case it was Raspberry Pi 3. This becomes important when downloading the balenaOS image to flash.

It's time to add your first device!

Make sure to toggle to a development edition of balenaOS as this will make playing around with and debugging your applications easier. It will also allow you to SSH into the host or app on the device over the local network.

You should also enter your WiFi details so that your device can access the internet. Alternatively just hook it up to your router via ethernet.

Adding a new device to your application on balenaCloud.

Now you can go ahead and download and flash your image to a microSD card. I recommend using balenaEtcher. Then stick it into your Pi and power it up! It should automatically connect to your WiFi network and you should see it appear online on your balenaCloud dashboard.

<TODO>