varlink / go

Golang implementation of the Varlink protocol
https://godoc.org/github.com/varlink/go/varlink
Apache License 2.0
55 stars 57 forks source link

How does a "upgraded" connection work? #16

Closed ffromani closed 4 years ago

ffromani commented 4 years ago

I want to consume the podman interface through varlink. Specifically, I'm looking to use ExecContainer(). This method requires an "upgraded" connection

So I add the Upgrade flag to the Send()[1], but how will I get the content?

The call immediately returns an empty reply, and later, if I keep reading using the receive function I got from Send(), I'll get the output of the command I Exec-uted.

But I can't find in the doc how I'm supposed to know when and how much should I read, neither the format of the next replies (they don't seem JSON)

+++

[1] I'm experimenting with a patched version of go-varlink-cmd

johanbrandhorst commented 4 years ago

I found an example of this in the libpod source: https://github.com/containers/libpod/blob/b713e5371fa8767067bd2c329a3744ea593b2ade/pkg/adapter/runtime_remote.go#L550.

It seems after successfully calling the function returned from the initial call, you can just write straight to the connection. The protocol doesn't seem to be specified, but apparently you should expect a ':' as a response from a successful write :man_shrugging:.

Note that this kind of thing is not possible with current master, see https://github.com/varlink/go/issues/18.

ffromani commented 4 years ago

Hey, thanks for chiming in @johanbrandhorst . This was pretty much what I discovered independentyl experimenging with the code. I was thinkering with code in order to find a clean solution to send a PR, but I like your approach in https://github.com/varlink/go/issues/18, let's go this direction!

haraldh commented 4 years ago

It seems after successfully calling the function returned from the initial call, you can just write straight to the connection. The protocol doesn't seem to be specified, but apparently you should expect a ':' as a response from a successful write.

The : is part of podman's own protocol. With an upgraded connection you define the protocol. Varlink is not part of it anymore.

johanbrandhorst commented 4 years ago

Can close this with #19 merged

ffromani commented 4 years ago

Can close this with #19 merged

agreed

haraldh commented 4 years ago

you also want to look into https://github.com/haraldh/govarlinksendfileexample

for an upgrade example