So you want to use GoGo Protobuf

Introduction In the Go protobuf ecosystem there are two major implementations to choose from. There’s the official golang/protobuf, which uses reflection to marshal and unmarshal structs, and there’s gogo/protobuf, a third party implementation that leverages type-specific marshalling code for extra performance, and has many cool extensions you can use to customize the generated code. gogo/protobuf has been recommended as the best choice of Go serialization library in a large test of different implementations....

February 19, 2018 · 8 min

I was invited to a meetup

Introduction After my presentation at the Go London meetup I was approached on Gophers slack by a gentleman from Hungary called Máté Gulyás. Máté is one of the organisers of the Budapest Go Meetup, and was reaching out to me to ask if I would like to come down to Budapest and deliver a talk for the meetup. I was delighted with this invitation and promptly accepted and we started planning....

February 10, 2018 · 5 min

Client side streaming in gRPC-Web

In a previous post I introduced my open source project to bring GopherJS bindings to Improbable’s gRPC-Web client. I’m happy to say that the initial goal of supporting all features of the gRPC-Web client has been completed. I was initially going to leave it at that and wait for client side streaming to land in the WHATWG Streams API Standard, and subsequently added to the official grpc-web spec and probably the gRPC-Web client, but then I was sitting at the GolangUK conference and I had a brain wave....

September 17, 2017 · 3 min

Advanced CircleCI docker testing

In a recent blog post I talked about automating the testing of an advanced GopherJS library using a combination of QUnit, Ginkgo and Agouti. That allowed me to run a complete integration test suite against my library by automatically spinning up browsers and pointing them at my QUnit GopherJS page. This was a great start, but after running it a couple of times we find that there are several problems:...

August 4, 2017 · 5 min

Chunking large messages with gRPC

One of the gotchas of using gRPC is that it was not designed to transport large messages in one chunk. The default max message size is slightly arbitrarily set at 4MB today, and while it is possible to configure, that kind of behaviour might lead to a slippery slope scenario of ever increasing max message sizes. So what do we do when the message size is too large? We chunk the data into smaller pieces and stream it, using the gRPC streaming methods, naturally....

July 14, 2017 · 2 min

Throttling resource intensive requests

Sometimes when you’re writing a server, you’ve got a function that consumes a lot of memory while running, or some other resource, and you might be worrying that a sudden burst of requests could crash the server, since gRPC by default will just spawn another goroutine to handle any incoming requests, oblivious to the danger. In these situations, it can be useful to implement some custom request throttling. Here I’ll show an easy way to accomplish this with the use of a Go channel....

July 14, 2017 · 2 min

GopherJS Integration Tests

Recently I found myself wondering how I was going to test my new GopherJS gRPC-Web bindings. Writing tests was something I had been waiting with until I had something working, mostly because I had no idea how I was going to meaningfully test GopherJS code that relies on interactions with JS and the reponses of a server. I have in the past made a small contribution to the GopherJS websocket repo, and found myself impressed with the extensive tests written for the repo....

July 11, 2017 · 3 min

gRPC-Web with GopherJS

In a previous blog series I’ve talked about how to work with a gRPC backend from the GopherJS world. It relies on the gRPC-gateway which is a great piece of tech, but unfortunately carries a couple of downsides: Clients don’t know what types are used - the interface is HTTP JSON. This can be somewhat mitigated with the use of swagger generated interfaces, but it’s still not perfect. The interface being JSON means marshalling and unmarshalling can become a significant part of the latency between the client and the server....

June 20, 2017 · 4 min

Auto-deployment of your app from Github

Update Docker Cloud is being discontinued. For an alternative easy app deployment, check my new post on automatic app deployment. Furthermore, I would nowadays recommend Hetzner Cloud over Scaleway. Scaleway was running out of instances last time I tried using them, and Hetzner’s web console is much better than Scaleways. Old post preserved below. Introduction Yesterday (!) I asked in the Gophers slack for recommendations for deployment of static Go binaries, as I was in the process of deploying a demo for another blog post I’m working on....

June 4, 2017 · 5 min

Go Protobuf Tips

I’ve had my fair share of dealing with proto files in go (and to some extent JS), so I thought I’d share some stuff I’ve learnt the hard way by working with proto files. Protoc include paths The protoc include paths can be pretty confusing, so I’ll give a few examples of how to use it properly. Just include the current directory protoc requires that the files referenced are in the include path, so if you’re referencing files relative to the current directory, you’ll need to specify -I....

April 18, 2017 · 4 min