As a bit of a laugh, 6gu is a lovely little microservices framework. Or something. Flick a switch and you can make HTTP requests to “the spreadsheet” to evaluate its functions.

An example

In an old version of the demo spreadsheet (video on the front page), there was:

  • A distance function. This calculates the distance “as the crow flies” between two latitude/longitude pairs using the Haversine formula.
  • A nameDist function. This calculates the distance between two airports, given their IATA codes.

The microservices

There is a node server somewhere that has opened that spreadsheet, and it’s itching to tell you anything you want to know. It’ll even do some calculations for you.

In the spreadsheet, if you wanted to get the distance between a pair of airports (let’s say SFO and AKL) in a new sheet, you’d type something like this into a new cell:

nameDist(fromName: "SFO", toName: "AKL")

If you don’t want to open the spreadsheet, though, that’s fine – just ask the “airports distance microservice” that the spreadsheet exposes:

https://distance.service.6gu.nz/s1.nameDist?fromName="SFO"&toName="AKL"

Pretty neat, huh? You can use any valid JSON for the arguments, and because it’s really running the real spreadsheet code, you can do cool things like ask for the distance between multiple airports at a time:

https://distance.service.6gu.nz/s1.nameDist?fromName="SFO"&toName=["AKL","MEX","HNL"]

Get excited!

Open questions

I haven’t figured out the logic behind spinning up and shutting down these microservices things. This one was (will be…) provisioned manually. I guess I could automate putting them on AWS lambda or something, though…

Other things to figure out:

  • Can/should requests mutate data in the spreadsheet?

  • Can/should the microservice talk to an external database or make requests to other APIs? Or is it just “pure function, request/response”?

  • Should the user be able to “request” expressions that aren’t straight function calls?

  • Should the spreadsheet writer be able to make some cells private?