From 958f2af516a84dffe45c8bec3ea2a9c093077238 Mon Sep 17 00:00:00 2001 From: Arsen Musayelyan Date: Thu, 12 May 2022 17:14:34 -0700 Subject: [PATCH] Propagate context to lrpc --- go.mod | 2 +- go.sum | 4 ++-- main.go | 2 +- socket.go | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 825bd36..41b74e5 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/rs/zerolog v1.26.1 github.com/urfave/cli/v2 v2.3.0 go.arsenm.dev/infinitime v0.0.0-20220511202257-9ed74726c478 - go.arsenm.dev/lrpc v0.0.0-20220510090735-af77b121f888 + go.arsenm.dev/lrpc v0.0.0-20220513001344-3bcc01fdb6a0 golang.org/x/text v0.3.7 modernc.org/sqlite v1.17.2 ) diff --git a/go.sum b/go.sum index 7110a47..1110025 100644 --- a/go.sum +++ b/go.sum @@ -398,8 +398,8 @@ github.com/yuin/goldmark v1.4.4 h1:zNWRjYUW32G9KirMXYHQHVNFkXvMI7LpgNW2AgYAoIs= github.com/yuin/goldmark v1.4.4/go.mod h1:rmuwmfZ0+bvzB24eSC//bk1R1Zp3hM0OXYv/G2LIilg= go.arsenm.dev/infinitime v0.0.0-20220511202257-9ed74726c478 h1:HO+fteXuSnnT7po1PhGJK6nk8qMAGN2RqDaVP4sRN8g= go.arsenm.dev/infinitime v0.0.0-20220511202257-9ed74726c478/go.mod h1:1cBQ3fp6QlRbSqu9kEBAHsVThINj31FtqHIYVsQ7wgg= -go.arsenm.dev/lrpc v0.0.0-20220510090735-af77b121f888 h1:WrcoTvWsmg5YHq/nWRBMdcRlNfFPfVtfi6eBEVyod8w= -go.arsenm.dev/lrpc v0.0.0-20220510090735-af77b121f888/go.mod h1:goK9z735lfXmqlDxu9qN7FS8t0HJHN3PjyDtCToUY4w= +go.arsenm.dev/lrpc v0.0.0-20220513001344-3bcc01fdb6a0 h1:1K96g1eww+77GeGchwMhd0NTrs7Mk/Hc3M3ItW5NbG4= +go.arsenm.dev/lrpc v0.0.0-20220513001344-3bcc01fdb6a0/go.mod h1:goK9z735lfXmqlDxu9qN7FS8t0HJHN3PjyDtCToUY4w= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= diff --git a/main.go b/main.go index a768446..dbb567d 100644 --- a/main.go +++ b/main.go @@ -179,7 +179,7 @@ func main() { } // Start control socket - err = startSocket(dev) + err = startSocket(ctx, dev) if err != nil { log.Error().Err(err).Msg("Error starting socket") } diff --git a/socket.go b/socket.go index 89e4bb3..5dba567 100644 --- a/socket.go +++ b/socket.go @@ -19,6 +19,7 @@ package main import ( + "context" "errors" "io" "net" @@ -40,7 +41,7 @@ var ( ErrDFUInvalidUpgType = errors.New("invalid upgrade type") ) -func startSocket(dev *infinitime.Device) error { +func startSocket(ctx context.Context, dev *infinitime.Device) error { // Make socket directory if non-existant err := os.MkdirAll(filepath.Dir(k.String("socket.path")), 0755) if err != nil { @@ -83,7 +84,7 @@ func startSocket(dev *infinitime.Device) error { return err } - go srv.Serve(ln, codec.Default) + go srv.Serve(ctx, ln, codec.Default) // Log socket start log.Info().Str("path", k.String("socket.path")).Msg("Started control socket")