From 509da8ebd1cb4f76eae0ffed179b9af1be73f8dd Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Thu, 23 Oct 2025 16:29:21 +0200 Subject: add varlink note MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- site/index.html | 1 + site/notes.html | 1 + site/varlink.html | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/inc/index.htm | 1 + src/inc/notes.htm | 1 + src/inc/notes.md | 1 + src/inc/varlink.htm | 33 ++++++++++++++++++++++ src/inc/varlink.md | 42 ++++++++++++++++++++++++++++ 8 files changed, 160 insertions(+) create mode 100644 site/varlink.html create mode 100644 src/inc/varlink.htm create mode 100644 src/inc/varlink.md diff --git a/site/index.html b/site/index.html index 006cb55..582fed3 100644 --- a/site/index.html +++ b/site/index.html @@ -56,6 +56,7 @@
  • sony-wf1000xm3-battery
  • toyama
  • unicode-range
  • +
  • varlink
  • yamanashi
  • diff --git a/site/notes.html b/site/notes.html index 1f0d01b..625e636 100644 --- a/site/notes.html +++ b/site/notes.html @@ -34,6 +34,7 @@
      +
    • 2025-11-12 — varlink
    • 2025-05-14 — porta
    • 2025-03-07 — unicode-range
    • 2025-01-24 — plan9-cursors
    • diff --git a/site/varlink.html b/site/varlink.html new file mode 100644 index 0000000..184fdb3 --- /dev/null +++ b/site/varlink.html @@ -0,0 +1,80 @@ + + + + + + + + + + + + +gzr.im — varlink + + +
      +gzr.im + +
      +
      + +

      varlink is a neat +little standard for doing debuggable IPC. It takes some of the nice +properties of DBUS, like the introspection capabilities, and combines +them with simple standard tools/technologies in the form of unix sockets +and JSON.

      +

      For C, there is a library by emersion called vali, which does pretty much all you +need to get going: https://emersion.fr/blog/2025/announcing-vali/

      +

      When you have written your service, here is how to interact with it +just using standard utils, socat and jq:

      +
      cat <<-EOF | jq --raw-output0 | socat STDIO UNIX-CONNECT:"$SOCKET" | jq
      +    {
      +        "method": "org.varlink.service.GetInfo",
      +    }
      +EOF
      +

      This is equivalent to using the varlink cli tool and running: +varlink info $SOCKET

      +
      cat <<-EOF | jq --raw-output0 | socat STDIO UNIX-CONNECT:"$SOCKET" | jq
      +    {
      +        "method": "org.varlink.service.GetInterfaceDescription",
      +        "parameters": {
      +            "interface": "com.example.Foobar"
      +        }
      +    }
      +EOF
      +

      This will return the service interface (if the service listening at +the socket actually implements it.

      +

      Note the use of jq --raw-output0. It is possible to omit +the jq invocations, the input JSON data should be followed by a NUL +byte.

      +
      + +[⏶] + + diff --git a/src/inc/index.htm b/src/inc/index.htm index fdd90d9..66353ee 100644 --- a/src/inc/index.htm +++ b/src/inc/index.htm @@ -22,5 +22,6 @@
    • sony-wf1000xm3-battery
    • toyama
    • unicode-range
    • +
    • varlink
    • yamanashi
    diff --git a/src/inc/notes.htm b/src/inc/notes.htm index a6f9d3f..fbf96f3 100644 --- a/src/inc/notes.htm +++ b/src/inc/notes.htm @@ -1,5 +1,6 @@
      +
    • 2025-11-12 — {varlink}
    • 2025-05-14 — {porta}
    • 2025-03-07 — {unicode-range}
    • 2025-01-24 — {plan9-cursors}
    • diff --git a/src/inc/notes.md b/src/inc/notes.md index 56f0b7b..0d6d298 100644 --- a/src/inc/notes.md +++ b/src/inc/notes.md @@ -1,3 +1,4 @@ +* `2025-11-12` — {varlink} * `2025-05-14` — {porta} * `2025-03-07` — {unicode-range} * `2025-01-24` — {plan9-cursors} diff --git a/src/inc/varlink.htm b/src/inc/varlink.htm new file mode 100644 index 0000000..7de95de --- /dev/null +++ b/src/inc/varlink.htm @@ -0,0 +1,33 @@ + +

      varlink is a neat +little standard for doing debuggable IPC. It takes some of the nice +properties of DBUS, like the introspection capabilities, and combines +them with simple standard tools/technologies in the form of unix sockets +and JSON.

      +

      For C, there is a library by emersion called vali, which does pretty much all you +need to get going: https://emersion.fr/blog/2025/announcing-vali/

      +

      When you have written your service, here is how to interact with it +just using standard utils, socat and jq:

      +
      cat <<-EOF | jq --raw-output0 | socat STDIO UNIX-CONNECT:"$SOCKET" | jq
      +    {
      +        "method": "org.varlink.service.GetInfo",
      +    }
      +EOF
      +

      This is equivalent to using the varlink cli tool and running: +varlink info $SOCKET

      +
      cat <<-EOF | jq --raw-output0 | socat STDIO UNIX-CONNECT:"$SOCKET" | jq
      +    {
      +        "method": "org.varlink.service.GetInterfaceDescription",
      +        "parameters": {
      +            "interface": "com.example.Foobar"
      +        }
      +    }
      +EOF
      +

      This will return the service interface (if the service listening at +the socket actually implements it.

      +

      Note the use of jq --raw-output0. It is possible to omit +the jq invocations, the input JSON data should be followed by a NUL +byte.

      diff --git a/src/inc/varlink.md b/src/inc/varlink.md new file mode 100644 index 0000000..bb65dea --- /dev/null +++ b/src/inc/varlink.md @@ -0,0 +1,42 @@ +[varlink][1] is a neat little standard for doing debuggable IPC. It takes some +of the nice properties of DBUS, like the introspection capabilities, and +combines them with simple standard tools/technologies in the form of unix +sockets and JSON. + +For C, there is a library by [emersion][2] called vali, which does pretty much +all you need to get going: https://emersion.fr/blog/2025/announcing-vali/ + +When you have written your service, here is how to interact with it just using +standard utils, socat and jq: + +```sh +cat <<-EOF | jq --raw-output0 | socat STDIO UNIX-CONNECT:"$SOCKET" | jq + { + "method": "org.varlink.service.GetInfo", + } +EOF +``` + +This is equivalent to using the varlink cli tool and running: +`varlink info $SOCKET` + +```sh +cat <<-EOF | jq --raw-output0 | socat STDIO UNIX-CONNECT:"$SOCKET" | jq + { + "method": "org.varlink.service.GetInterfaceDescription", + "parameters": { + "interface": "com.example.Foobar" + } + } +EOF +``` + +This will return the service interface (if the service listening at the socket +actually implements it. + +Note the use of `jq --raw-output0`. It is possible to omit the jq invocations, +the input JSON data should be followed by a NUL byte. + + +[1]: https://varlink.org +[2]: https://emersion.fr -- cgit 1.4.1