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:
parent
3a3f0aac88
commit
8c5779c32b
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,
|
||||||
|
@ -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),
|
||||||
|
@ -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
|
||||||
|
21
vendor/github.com/containerd/ttrpc/client.go
generated
vendored
21
vendor/github.com/containerd/ttrpc/client.go
generated
vendored
@ -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)
|
||||||
|
2
vendor/github.com/containerd/ttrpc/services.go
generated
vendored
2
vendor/github.com/containerd/ttrpc/services.go
generated
vendored
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user