/usr/share/gocode/src/github.com/hashicorp/net-rpc-msgpackrpc/client.go is in golang-github-hashicorp-net-rpc-msgpackrpc-dev 0.0~git20151015.0.d31f7b9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | package msgpackrpc
import (
"errors"
"net/rpc"
"sync/atomic"
"github.com/hashicorp/go-multierror"
)
var (
// nextCallSeq is used to assign a unique sequence number
// to each call made with CallWithCodec
nextCallSeq uint64
)
// CallWithCodec is used to perform the same actions as rpc.Client.Call but
// in a much cheaper way. It assumes the underlying connection is not being
// shared with multiple concurrent RPCs. The request/response must be syncronous.
func CallWithCodec(cc rpc.ClientCodec, method string, args interface{}, resp interface{}) error {
request := rpc.Request{
Seq: atomic.AddUint64(&nextCallSeq, 1),
ServiceMethod: method,
}
if err := cc.WriteRequest(&request, args); err != nil {
return err
}
var response rpc.Response
if err := cc.ReadResponseHeader(&response); err != nil {
return err
}
if response.Error != "" {
err := errors.New(response.Error)
if readErr := cc.ReadResponseBody(nil); readErr != nil {
err = multierror.Append(err, readErr)
}
return rpc.ServerError(err.Error())
}
if err := cc.ReadResponseBody(resp); err != nil {
return err
}
return nil
}
|