bump containerd/ttrpc 699c4e40d1e7416e08bf7019c7ce2e9beced4636

full diff: f02858b145...699c4e40d1

- containerd/ttrpc#33 Fix returns error message
- containerd/ttrpc#35 Make onclose an option

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-04-27 15:30:18 -07:00
parent 3a3f0aac88
commit 8c5779c32b
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
6 changed files with 19 additions and 15 deletions

View File

@ -219,8 +219,7 @@ func WithConnect(address string, onClose func()) Opt {
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
client := ttrpc.NewClient(conn) client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
client.OnClose(onClose)
return shimapi.NewShimClient(client), conn, nil return shimapi.NewShimClient(client), conn, nil
} }
} }

View File

@ -96,8 +96,7 @@ func (b *binary) Start(ctx context.Context) (_ *shim, err error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
client := ttrpc.NewClient(conn) client := ttrpc.NewClient(conn, ttrpc.WithOnClose(func() { _ = conn.Close() }))
client.OnClose(func() { conn.Close() })
return &shim{ return &shim{
bundle: b.bundle, bundle: b.bundle,
client: client, client: client,

View File

@ -74,8 +74,7 @@ func loadShim(ctx context.Context, bundle *Bundle, events *exchange.Exchange, rt
} }
}() }()
client := ttrpc.NewClient(conn) client := ttrpc.NewClient(conn, ttrpc.WithOnClose(func() { _ = conn.Close() }))
client.OnClose(func() { conn.Close() })
s := &shim{ s := &shim{
client: client, client: client,
task: task.NewTaskClient(client), task: task.NewTaskClient(client),

View File

@ -37,7 +37,7 @@ github.com/Microsoft/go-winio 84b4ab48a50763fe7b3abcef38e5205c12027fac
github.com/Microsoft/hcsshim 8abdbb8205e4192c68b5f84c31197156f31be517 github.com/Microsoft/hcsshim 8abdbb8205e4192c68b5f84c31197156f31be517
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4 golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4
github.com/containerd/ttrpc f02858b1457c5ca3aaec3a0803eb0d59f96e41d6 github.com/containerd/ttrpc 699c4e40d1e7416e08bf7019c7ce2e9beced4636
github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2 github.com/syndtr/gocapability d98352740cb2c55f81556b63d4a1ec64c5a319c2
gotest.tools v2.3.0 gotest.tools v2.3.0
github.com/google/go-cmp v0.2.0 github.com/google/go-cmp v0.2.0

View File

@ -49,7 +49,15 @@ type Client struct {
err error err error
} }
func NewClient(conn net.Conn) *Client { type ClientOpts func(c *Client)
func WithOnClose(onClose func()) ClientOpts {
return func(c *Client) {
c.closeFunc = onClose
}
}
func NewClient(conn net.Conn, opts ...ClientOpts) *Client {
c := &Client{ c := &Client{
codec: codec{}, codec: codec{},
conn: conn, conn: conn,
@ -60,6 +68,10 @@ func NewClient(conn net.Conn) *Client {
closeFunc: func() {}, closeFunc: func() {},
} }
for _, o := range opts {
o(c)
}
go c.run() go c.run()
return c return c
} }
@ -141,11 +153,6 @@ func (c *Client) Close() error {
return nil return nil
} }
// OnClose allows a close func to be called when the server is closed
func (c *Client) OnClose(closer func()) {
c.closeFunc = closer
}
type message struct { type message struct {
messageHeader messageHeader
p []byte p []byte
@ -255,7 +262,7 @@ func (c *Client) recv(resp *Response, msg *message) error {
} }
if msg.Type != messageTypeResponse { if msg.Type != messageTypeResponse {
return errors.New("unkown message type received") return errors.New("unknown message type received")
} }
defer c.channel.putmbuf(msg.p) defer c.channel.putmbuf(msg.p)

View File

@ -76,7 +76,7 @@ func (s *serviceSet) dispatch(ctx context.Context, serviceName, methodName strin
switch v := obj.(type) { switch v := obj.(type) {
case proto.Message: case proto.Message:
if err := proto.Unmarshal(p, v); err != nil { if err := proto.Unmarshal(p, v); err != nil {
return status.Errorf(codes.Internal, "ttrpc: error unmarshaling payload: %v", err.Error()) return status.Errorf(codes.Internal, "ttrpc: error unmarshalling payload: %v", err.Error())
} }
default: default:
return status.Errorf(codes.Internal, "ttrpc: error unsupported request type: %T", v) return status.Errorf(codes.Internal, "ttrpc: error unsupported request type: %T", v)