Merge pull request #3246 from thaJeztah/bump_ttrpc

bump containerd/ttrpc 699c4e40d1e7416e08bf7019c7ce2e9beced4636
This commit is contained in:
Michael Crosby 2019-04-29 17:32:19 -04:00 committed by GitHub
commit bf5a424679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 {
return nil, nil, err
}
client := ttrpc.NewClient(conn)
client.OnClose(onClose)
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(onClose))
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 {
return nil, err
}
client := ttrpc.NewClient(conn)
client.OnClose(func() { conn.Close() })
client := ttrpc.NewClient(conn, ttrpc.WithOnClose(func() { _ = conn.Close() }))
return &shim{
bundle: b.bundle,
client: client,

View File

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

View File

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

View File

@ -49,7 +49,15 @@ type Client struct {
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{
codec: codec{},
conn: conn,
@ -60,6 +68,10 @@ func NewClient(conn net.Conn) *Client {
closeFunc: func() {},
}
for _, o := range opts {
o(c)
}
go c.run()
return c
}
@ -141,11 +153,6 @@ func (c *Client) Close() error {
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 {
messageHeader
p []byte
@ -255,7 +262,7 @@ func (c *Client) recv(resp *Response, msg *message) error {
}
if msg.Type != messageTypeResponse {
return errors.New("unkown message type received")
return errors.New("unknown message type received")
}
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) {
case proto.Message:
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:
return status.Errorf(codes.Internal, "ttrpc: error unsupported request type: %T", v)