The varlink.org Website
varlink / go Goto Github PK
View Code? Open in Web Editor NEWGolang implementation of the Varlink protocol
Home Page: https://godoc.org/github.com/varlink/go/varlink
License: Apache License 2.0
Golang implementation of the Varlink protocol
Home Page: https://godoc.org/github.com/varlink/go/varlink
License: Apache License 2.0
The varlink.org Website
It would be nice to be able to set a Logger on a Service so that errors returned from call handlers can be debugged more easily.
It would be good to have a go.mod
file so that dependants of this repo can resolve transitive dependencies correctly. Even for packages that only use the standard library this is a best practice.
errormessage:
varlinkbridge_windows.go:47:9: cannot use PipeCon literal (type PipeCon) as type *ctxio.Conn in assignment
varlink\bridge_windows.go:49:3: c.Reader undefined (type Connection has no field or method Reader)
varlink\[email protected]\varlink\bridge_windows.go:50:3: c.Writer undefined (type Connection has no field or method Writer)
i changed it the same code in bridge.c
Adding import
"github.com/varlink/go/varlink/internal/ctxio"
change line 48-1:
c.conn = ctxio.NewConn(PipeCon{nil, cmd, &r, &w})
remove lines:
//c.Reader = bufio.NewReader(r)
//c.Writer = bufio.NewWriter(w)
Is this correct ?
diff --git "a/varlink/bridge_windows.go" "b/varlink/bridge_windows.go"
index 42953b8..26ec6b2 100644
--- "a/varlink/bridge_windows.go"
+++ "b/varlink/bridge_windows.go"
@@ -1,11 +1,12 @@
package varlink
import (
- "bufio"
"io"
"net"
"os"
"os/exec"
+
+ "github.com/varlink/go/varlink/internal/ctxio"
)
type PipeCon struct {
@@ -44,10 +45,8 @@ func NewBridgeWithStderr(bridge string, stderr io.Writer) (*Connection, error) {
if err != nil {
return nil, err
}
- c.conn = PipeCon{nil, cmd, &r, &w}
+ c.conn = ctxio.NewConn(PipeCon{nil, cmd, &r, &w})
c.address = ""
- c.Reader = bufio.NewReader(r)
- c.Writer = bufio.NewWriter(w)
err = cmd.Start()
if err != nil {
there isn't anything on the main site or any of the repositories that i'm seeing on how to go from a varlink file to a go package. (I'm assuming a code generator is used...)
I am not sure if this is a bug in your implementation or systemd not implementing the spec correctly
But systemd defines a varlink interface here:
https://systemd.io/USER_GROUP_API/
But this library fails to parse it with the following error:
Error parsing file 'io.systemd.UserDatabase.varlink': unknown keyword ''
Trial and error seems to suggest this library is choking over the fact that UserDatabase
is capitalized in the interface name. Are interface definitions not allowed to have capital letters in them? Or is this a bug in this library?
interface io.systemd.UserDatabase
method GetUserRecord(
uid : ?int,
userName : ?string,
service : string
) -> (
record : object,
incomplete : bool
)
method GetGroupRecord(
gid : ?int,
groupName : ?string,
service : string
) -> (
record : object,
incomplete : bool
)
method GetMemberships(
userName : ?string,
groupName : ?string,
service : string
) -> (
userName : string,
groupName : string
)
error NoRecordFound()
error BadService()
error ServiceNotAvailable()
error ConflictingRecordFound()
error EnumerationNotSupported()
We are currently facing a bug in Podman (i.e., libpod) described here: containers/podman#888
Service.parseError
ultimately leads to an out of range error when the passed string doesn't match the expected format (see https://github.com/varlink/go/blob/master/varlink/service.go#L199). I suggest using net/url
for parsing strings, where URI.Scheme
can be used to check the supported protocols etc.
How do you wait for events as shown in the docs? I can't see anything that take a context
, so I'm assuming it's missing or built incorrectly? Eg from the FAQ:
How can I monitor changes or subscribe to signals?
Varlink connections can be turned into monitor connections, they are soft-negotiated between the client and the service. The client asks the server to possibly reply with more than one reply, the server replies and indicates that it might have more replies and the client should wait for them.
How do I do this in golang?
Additionally, you might want to change this type of interface:
https://godoc.org/github.com/varlink/go/varlink#Connection.Call
func (c *Connection) Call(method string, parameters interface{}, out_parameters interface{}) error
To something that takes a number of functions that return a param. Eg:
func (c *Connection) Call(method string, in []Param, out []Param) error
func BoolParam(value bool) Param
func IntParam(value bool) Param
func WhateverParam(value bool) Param
HTH
Use context methods in all calls that may block on the network.
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
It would be great to have a formal semantic releases please.
Thank you.
The recent change to use a context in all calls also took the liberty of hiding access to the Reader and Writers of the raw connection. Turns out this is sometimes necessary when using the varlink connection, for upgraded connections. See https://github.com/containers/libpod/blob/b713e5371fa8767067bd2c329a3744ea593b2ade/pkg/adapter/runtime_remote.go#L550 for example.
I propose adding a helper that does the first half of that function all in one and return a Reader and Writer from the function.
I intend to prototype this.
The generated errors error string currently only includes the type name, which is very annoying to handle in applications and for debugging unexpected errors. I propose we add more metadata to the error strings, for example adding the fields of the error to the string.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.