MessagePack for CLI responses

Dridi Boukelmoune dridi at
Fri Aug 5 12:54:26 CEST 2016

Hi all,

This is just a thought dump sent from my phone, because I will likely
forget all about it by the time I get to my laptop again.

I've come across MessagePack (mp) in the past [1] and didn't think much
about it, for some reason it recently occurred to me it could be a good fit
for the CLI.

mp is a binary equivalent to json, and it's no secret that I really don't
like json for general purpose serialization (read: unless it's consumed by
JavaScript, and I don't hold JavaScript dear in my heart). However mp has
some interesting boundaries for types that don't exist with json.

The CLI could get structured responses from the child serialized as mp
instead of plain text.

It could either be the current scheme of a line containing metadata about
the response followed by a payload, or a single mp response containing the
status and the structured response.

I like the latter better because the response could be streamed instead of
built upfront. It could improve the situation when you have thousands of
backends for instance.

If the CLI is binary, it's no longer human-friendly. However the
responsibility of rendering could be shift in varnishadm with the
possibility of outputting either json or plain text. Setups (like
varnish-agent) relying on -T or -M would need to understand mp, possibly
with the help of libvarnishapi.

Having structured responses could also mean the introduction of schemas.
With the need for versioning of the CLI protocol similar to VRT (breaking
vs adding).

Commands handled by the manager should obviously also speak mp too.

The spec [2] is very straightforward and even allows extension points,
although I don't think we'd need any. Native support for blobs too, but
again I don't see a use case for the CLI.

varnishstat could also have mp rendering in addition to the existing XML
and json.

Dridi, enjoying cloudy-but-sunny Hamburg

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the varnish-dev mailing list